471,570 Members | 902 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Call method on a form from another thread

I am looking for a sample of how you execute/invoke a method in a form from
one thread and have it run on the thread that created the form instead of
the thread that actually made the call. The reason I need this is because
the method that gets invoked could be updating any number of GUI elements on
the form.

What would be ideal is to have the code in the thread an not the form since
I will have several of these forms.

Also, do delegates perform this action themselves? What I mean is if I
delegate is declared as part of one thread but a handler is registered by
another thread does it make sure it executes on the correct thread?

Thanks.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jan 29 '06 #1
1 2441
John Skeet has a very good article on threading in .Net, one section is
dedicated to threading issues in Windows Forms, it should answer your
questions:

http://www.yoda.arachsys.com/csharp/...winforms.shtml

Mark Dawson
http://www.markdawson.org

"C.C. (aka Me)" wrote:
I am looking for a sample of how you execute/invoke a method in a form from
one thread and have it run on the thread that created the form instead of
the thread that actually made the call. The reason I need this is because
the method that gets invoked could be updating any number of GUI elements on
the form.

What would be ideal is to have the code in the thread an not the form since
I will have several of these forms.

Also, do delegates perform this action themselves? What I mean is if I
delegate is declared as part of one thread but a handler is registered by
another thread does it make sure it executes on the correct thread?

Thanks.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jan 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dan | last post: by
reply views Thread by Pawan Narula via DotNetMonster.com | last post: by
5 posts views Thread by Paul Hasell | last post: by
4 posts views Thread by Paul | last post: by
46 posts views Thread by Steven T. Hatton | last post: by
6 posts views Thread by HolyShea | last post: by
7 posts views Thread by =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post: by
9 posts views Thread by =?iso-8859-1?Q?Jos=E9_Joye?= | last post: by
1 post views Thread by =?Utf-8?B?RGF2ZQ==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | 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.