Home All Groups Group Topic Archive Search About

update ui with delegate

Author
13 Apr 2005 7:20 PM
norm
HELP

I have component that need to update the UI.
The component raises an event on the main form which update the UI.
Every time I execute the event I get an error that state the controls must
be on the same thread

I think I need to use delegate to update the UI.
I have created a delegate, but the update is still on the component thread
not the main UI thread.

I know I am doing something wrong, but can not get it worked out.
My knowledge of delegates is not great.

Can somebody give me an answer to this problem

Thanks
Norm

Author
13 Apr 2005 7:36 PM
Tom Shelton
In article <OW1yR3FQFHA.2***@TK2MSFTNGP15.phx.gbl>, norm wrote:
Show quoteHide quote
> HELP
>
> I have component that need to update the UI.
> The component raises an event on the main form which update the UI.
> Every time I execute the event I get an error that state the controls must
> be on the same thread
>
> I think I need to use delegate to update the UI.
> I have created a delegate, but the update is still on the component thread
> not the main UI thread.
>
> I know I am doing something wrong, but can not get it worked out.
> My knowledge of delegates is not great.
>
> Can somebody give me an answer to this problem
>
> Thanks
> Norm
>
>

You need to look at the documentation for Control.Invoke...  Using this
method, it will cause the function to be called on the thread the
control is on.

--
Tom Shelton [MVP]
Author
13 Apr 2005 9:26 PM
Herfried K. Wagner [MVP]
"norm" <n*@nn.com> schrieb:
> I have component that need to update the UI.
> The component raises an event on the main form which update the UI.
> Every time I execute the event I get an error that state the controls must
> be on the same thread
>
> I think I need to use delegate to update the UI.
> I have created a delegate, but the update is still on the component thread
> not the main UI thread.

In addition to the other replies:

Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>