G
Guest
Hi,
I have an app with the main thread and one additional thread.
In the main thread I defined an event handler MyHandler, the function for
raisin this event OnMyEvent and the function for processing this event MyFunc.
I want to raise this event from the second thread. Is it thread safe to call
the method OnMyEvent from this second thread?
In Win32 with C++ I waas just sending WM messages between threads. Does work
OnMyEvent overloaded method the same way, so I could call it from different
threads?
public event MyEventHandler MyEvent;
MyEvent += new MyEventHandler (MyFunc);
protected virtual void OnMyEvent( EventsArgs e)
{
MyEventHandler handler = MyEvent;
if (handler != null)
{
handler(this,e);
}
}
void MyFunc( object sender, EventArgs e)
{
....
}
Thanks,
Lubomir
I have an app with the main thread and one additional thread.
In the main thread I defined an event handler MyHandler, the function for
raisin this event OnMyEvent and the function for processing this event MyFunc.
I want to raise this event from the second thread. Is it thread safe to call
the method OnMyEvent from this second thread?
In Win32 with C++ I waas just sending WM messages between threads. Does work
OnMyEvent overloaded method the same way, so I could call it from different
threads?
public event MyEventHandler MyEvent;
MyEvent += new MyEventHandler (MyFunc);
protected virtual void OnMyEvent( EventsArgs e)
{
MyEventHandler handler = MyEvent;
if (handler != null)
{
handler(this,e);
}
}
void MyFunc( object sender, EventArgs e)
{
....
}
Thanks,
Lubomir