Z
Zürcher See
The event is thread safe? If a class call a delegate for an event, is the
class thread to execute the code or is the thread that has itself registered
that execute the code?
In few words if a form contains an object with a working thread, and the
working thread want to update something on the form, is threadsafe the call
to the event?
//the form register itself for the UpdateSomethingOnTheForm event and than
call the StartTheWorkingThread() method
class MyClass
{
public event EventHandler UpdateSomethingOnTheForm;
public void StartTheWorkingThread()
{
ThreadPoll.QueueUserWorkingItem(new
WaitCallBack(this.TheWorkingThreadMethod));
}
public void TheWorkingThreadMethod(object state)
{
....working...
//Now I want to update something on the form, this is thread safe?
this.UpdateSomethingOnTheForm(this,new EventHalder());
...working...
}
}
class thread to execute the code or is the thread that has itself registered
that execute the code?
In few words if a form contains an object with a working thread, and the
working thread want to update something on the form, is threadsafe the call
to the event?
//the form register itself for the UpdateSomethingOnTheForm event and than
call the StartTheWorkingThread() method
class MyClass
{
public event EventHandler UpdateSomethingOnTheForm;
public void StartTheWorkingThread()
{
ThreadPoll.QueueUserWorkingItem(new
WaitCallBack(this.TheWorkingThreadMethod));
}
public void TheWorkingThreadMethod(object state)
{
....working...
//Now I want to update something on the form, this is thread safe?
this.UpdateSomethingOnTheForm(this,new EventHalder());
...working...
}
}