Suppose class Engine do something in another thread and raise events.
class Engine
{
Thread Worker;
public event ... EngineMessage;
public void Start()
{
Worker=new Thread(new ThreadStart(Run));
Worker.Start();
}
private Run()
{
..Do some length work....
under some condition, fires
this.EngineMessage(msg);
}
}
If I subscribe to this event in the Form and tries to set the message
to a TextBox, this causes InvalidOperationExeption since this message
is from another thread. I can use this.InvokeRequred at the form, but
can't I do this at the Engine class so that at the Form, I can handle
the message without using delegates? I mean in the Engine class , can
I somehow raise the event in the same thread as the one called Start()?