C
CJ Taylor
Hey Everyone,
Alright, now I cannot get this to work, I may be dumb and don't see it, but
sickness will do that every now and then.
So I have a program with 4 threads performing unique operations. Syncing
isn't really important in this, just 4 different watches that happen.
So anyways, these "watchers" are on these threads, all raise an event called
LogEvent to the main thread. LogEvent is in a module so it can be called
from anywhere (as long as its imported of course).
However, I want to hook into the shared event of LogEvent (called Notify) on
my main thread, and take some of the information that happens from this
shared event and post it on a form.
However, I keep getting an error that it can't invoke across threads.
However, I think I have done everything, but maybe I'm missing something.
here is the event handler code.
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AddHandler Logger.EventLogger.Notify, AddressOf EvtLog
End Sub
Private Sub EvtLog(ByVal sender As Object, ByVal e As Logger.LogEventArgs)
Dim tv_Node As TreeNode
tv_Node = New TreeNode(e.EventDate)
tv_Node.Tag = e.Source
tv_Node.Nodes.Add(e.Source)
' Me.tv_Events.Nodes.Add(tv_Node)
End Sub
Alright, now I cannot get this to work, I may be dumb and don't see it, but
sickness will do that every now and then.
So I have a program with 4 threads performing unique operations. Syncing
isn't really important in this, just 4 different watches that happen.
So anyways, these "watchers" are on these threads, all raise an event called
LogEvent to the main thread. LogEvent is in a module so it can be called
from anywhere (as long as its imported of course).
However, I want to hook into the shared event of LogEvent (called Notify) on
my main thread, and take some of the information that happens from this
shared event and post it on a form.
However, I keep getting an error that it can't invoke across threads.
However, I think I have done everything, but maybe I'm missing something.
here is the event handler code.
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AddHandler Logger.EventLogger.Notify, AddressOf EvtLog
End Sub
Private Sub EvtLog(ByVal sender As Object, ByVal e As Logger.LogEventArgs)
Dim tv_Node As TreeNode
tv_Node = New TreeNode(e.EventDate)
tv_Node.Tag = e.Source
tv_Node.Nodes.Add(e.Source)
' Me.tv_Events.Nodes.Add(tv_Node)
End Sub