Re: Monitoring Threads
Bill Sanders <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <DOTNET-WINFORMS%[email protected]> |
Kelly,
One very simple option would be to have your dll create a control on the
original thread before launching the background process... hang onto that
control, then at the end use your same "self-marshalling" trick to raise the
NewData event on the original thread:
Private Sub RaiseNewDataEvent(theNeededData As Object, ...)
If myDummyControlImUsingAsAThreadPortal.InvokeRequired Then
Dim d As New MyDelegate(AddressOf RaiseNewDataEvent)
myDummyControlImUsingAsAThreadPortal.Invoke(d, New Object()
{theNeededData, ...})
Else
RaiseEvent NewData(theNeededData, ...)
End If
End Sub
-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and
controls [mailto:[email protected]] On Behalf Of Kelly
Baker
Sent: Wednesday, March 28, 2007 8:37 PM
To: [email protected]
Subject: [DOTNET-WINFORMS] Monitoring Threads
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.
Thanks,
Kelly