471,337 Members | 1,080 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Threading with WinForm

How do I call a method in the main form from a thread? My thread will do
some work and update the progress in the main form continuously until end.
Do i use a method, a delegate or a callback?
Feb 9 '06 #1
3 1400
Hi,
"tinyabs" <no****@me.com> wrote in message
news:43********@news.starhub.net.sg...
How do I call a method in the main form from a thread? My thread will do
some work and update the progress in the main form continuously until end.
Do i use a method, a delegate or a callback?

You need a reference to one control in the UI (like the progressbar) and
call Control.Invoke

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 9 '06 #2
You can't modify the UI from a thread different than the one created the
control. To marshal the call look at look at Control.InvokeRequired,
Control.Invoke and Control.BeginInvoke memebers.

I'd also suggest reading through the following articles:
http://msdn.microsoft.com/library/de...ms06112002.asp

http://msdn.microsoft.com/library/de...ms08162002.asp
--
HTH
Stoitcho Goutsev (100)

"tinyabs" <no****@me.com> wrote in message
news:43********@news.starhub.net.sg...
How do I call a method in the main form from a thread? My thread will do
some work and update the progress in the main form continuously until end.
Do i use a method, a delegate or a callback?

Feb 9 '06 #3
tinyabs <no****@me.com> wrote:
How do I call a method in the main form from a thread? My thread will do
some work and update the progress in the main form continuously until end.
Do i use a method, a delegate or a callback?


See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Eric | last post: by
8 posts views Thread by Z D | last post: by
3 posts views Thread by Elliot Rodriguez | last post: by
8 posts views Thread by Sunil Menon | last post: by
7 posts views Thread by Anthony Nystrom | last post: by
3 posts views Thread by Richard MSL | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.