I've read some documentation about accessing objects created in other
threads and the code below is similar to what I've gathered for what I have
to do:
private delegate void SetCursorCallBa ck(Cursor cursor);
// - Checks to see if the current thread is the creator of the current Form.
If the form was
// created on another thread, call Invoke so the delegate is ran in the
creating thread.
private void SetCursor(Curso r cursor)
{
if (this.InvokeReq uired()) {
SetCursorCallBa ck callBack = new SetCursorCallBa ck(SetCursor);
Invoke(callBack , cursor);
} else {
this.Cursor = cursor;
}
}
// This event gets fired in the secondary thread (not the thread that
created the form).
private void SomeVarName_Som eEventFiredFrom AnotherThread(
object sender,
EventArgs e
)
{
SetCursor(Curso rs.Default);
}
The comments in the code above are for YOUR consumption, this isn't exactly
what I have as I have snipped quite a bit of the custom code that is
irrelevant.
Is there a less-involved way to accomplish setting the properties of an
object created in a thread other than the current thread? If not, I can do
this fine, and I understand it, just wondering :)
Thanks,
Mythran