473,408 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 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 2564
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan | last post by:
Good Day, I have a Windows Service that is responsible for processing somes files. One method of the service invokes another method which may take a while to complete its work. Something like...
0
by: Pawan Narula via DotNetMonster.com | last post by:
hi all, i'm using VB.NET and trying to code for contact management in a tree. all my contacts r saved in a text file and my C dll reads them one by one and sends to VB callback in a sync mode...
5
by: Paul Hasell | last post by:
Hi, I'm trying to invoke a web method asynchronously but just can't seem to get it to tell me when it has finished! Below is the code I am (currently) using: private void...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
6
by: HolyShea | last post by:
All, Not sure if this is possible or not - I've created a class which performs an asynchronous operation and provides notification when the operation is complete. I'd like the notification to be...
7
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am trying to see if I can call a Library remotely. The library contains a Form that I want to display then pass back some data to user that called this form remotely. I have it working...
9
by: =?iso-8859-1?Q?Jos=E9_Joye?= | last post by:
I'm currently running some tests with WCF in In-proc environment. I have created a small winform application that starts the host in the main thread with an named pipe endpoint. If I call a...
1
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I have a class that Form1 calls to do some work. I would like to report back progress from the class to a richtextbox, will call it m_report, on the form. Like in the class, Form1.m_report.Text=...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.