Re: Monitoring Threads
Peter Ritchie <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Sorry, I should have been more clear. What Patrick said, System.Timers.Timer uses a background thread. Use System.Forms.Timer if you want to ensure your elapsed event timer is run on the GUI thread. On Wed, 28 Mar 2007 21:09:00 -0500, Kelly Baker <[email protected]> wrote: >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.