update ui with delegate

N

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
 
T

Tom Shelton

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.
 
H

Herfried K. Wagner [MVP]

norm said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top