Click here to Skip to main content
15,891,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to display progress messages for the user during a fairly lengthy import process. I tried writing to a TextBox whenever the Importer raises a progress event, but the textbox remains blank, even after the loop finishes. Then I tried using a ListBox, adding a new item for each progress event. No difference. I can see the event beinh caught and read the text, but just can't get it right to update my progress display.
Posted
Comments
[no name] 21-Sep-14 10:17am    
Are you using the Dispatcher?
Brady Kelly 21-Sep-14 10:26am    
No, my WPF noviseness excludes the Dispatcher. I'm trying to data bind the text box to a model (just a string).

1 solution

This has nothing to do with "real time". I think all systems where CLR is implemented are not real-time OS. Let's forget it.

Perhaps you are just running an additional thread (not UI thread) and want UI to get updated in a loop. You cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900