Re: How to tell what thread is current

Kelly Baker <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
I need to know if the current thread is the same as the host form (the form in which my control is loaded).  This function raises an event which is used to update controls on the form, and if it is not the same thread as the host form, I need to know.

I am using a BackgroundWorker for my threading, and if I am not in the same thread as the form, I can call the UpdateProgress method of the BackgroundWorker.



Why do you need to know this?

And how do you define the "host" form?  An app could have several forms visible at a time -- which one is the host form?  And what about mutiple UI threads?

What is it you're trying to accomplish that needs this information?

--
Patrick Steele
http://weblogs.asp.net/psteele



-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Kelly Baker
Sent: Thursday, March 29, 2007 4:53 PM
To: [email protected]
Subject: [DOTNET-WINFORMS] How to tell what thread is current


I have a function in a control that may be called within different threads.  How can I tell if it is on the same thread as the host form?





_________________________________________________________________
Need personalized email and website? Look no further. It's easy
with Doteasy $0 Web Hosting! Learn more at www.doteasy.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.