Re: Monitoring Threads

Kelly Baker <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <002801c771a7$381e85b0$a85b9110$@com>
I'm trying NOT to call RunWorkerAsync from a background thread.  I am
running it in a System.Timers.Timer elapsed event.  Does the Timer
automatically run in a different thread?  That's what I wanted to find out
by monitoring what thread running what routines.  Is there a call that will
give me the thread ID as shown in the Thread window of the debugger?

Thanks,
Kelly

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and
controls [mailto:[email protected]] On Behalf Of Peter
Ritchie
Sent: Wednesday, March 28, 2007 8:28 PM
To: [email protected]
Subject: Re: [DOTNET-WINFORMS] Monitoring Threads

The completed and progress events are called on the same thread that calls
the RunWorkerAsync method.  If you call the RunWorkerAsync method on a
thread other than the GUI thread then you'll get cross-threading
exceptions when you try to access Control data from within those event
handlers.

Why are you calling RunWorkerAsync from a background thread?  I.e. what
are you trying to accomplish?  There's several ways to approach this, I'm
just trying to find out what way would be best.


On Wed, 28 Mar 2007 19:37:08 -0500, Kelly Baker
<[email protected]> wrote:

>I am still working on that dll that runs a process in a different thread,
>then raises a NewData event for the calling executable.  I have redone it
>using the BackgroundWorker class to do my threading.  I have a
>System.Timers.Timer object that runs the RunWorkerAsync method.  In the
>RunWorkerCompleted event I raise the NewData event.  But the executable
>still raises the cross-threading error when I try to update the form
>controls.  Is there a way to programmatically get the thread ID that is
>displayed on the Threads debug window?  I would like to log what thread is
>active with each operation until I can find where my problem is.
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.