Saturday, December 29, 2007

Raise events on main form from different thread.

I just saw this post on Nicola Delfino's blog. I run into this same thing that he provides the solution for.

Update WinForm interface from a different thread
Well, this is a typical issue when you have a thread that works (i.e. a Workflow) and a UI that needs to be updated.
Let assume that you have a WinFom and you need to update its windows Title from another thread. The other thread needs to call "UpdateTitle" public method of current Form instance.
In order to obtain that it works you need to implement "UpdateTitle".

See his original post for the code sample:Update WinForm interface from a different thread

More information on Control.InvokeRequired Property on MSDN.

No comments: