MultiThreaded form refresh

  • Thread starter Thread starter Ken Saganowski
  • Start date Start date
K

Ken Saganowski

Has anyone ever created a multiThreaded form that constantly refreshes
itself when doing tasks that take an extended period of time?
 
Ken,

Yes. Generally speaking, when you want to update the user interface
from a thread that did not create it, you will have to call the Invoke
method on a control created in the UI thread. You would then pass a
delegate with the method you want to call (which will update the UI), as
well as the values you want to pass to it.

Hope this helps.
 
what do you mean by "multithreaded form" exactly?
Do you refer, for example, at the form that is shown while you copy a file,
with a progress bar, that gets upgraded while the copy is in progress?

If this is the case, you have to create a worker thread that actually
performs the lenghty operation, and periodically updates some control (e.g.
progress bar) on the form. Remember that all the updates to the UI must be
done from the main thread: you have to use somecontrol.Invoke(...) to update
the UI from the wprker thread (Invoke causes a method to be executed on the
main thread).

Hope this helps
GV
 
Back
Top