M
Mythran
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 SetCursorCallBack(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(Cursor cursor)
{
if (this.InvokeRequired()) {
SetCursorCallBack callBack = new SetCursorCallBack(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_SomeEventFiredFromAnotherThread(
object sender,
EventArgs e
)
{
SetCursor(Cursors.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
threads and the code below is similar to what I've gathered for what I have
to do:
private delegate void SetCursorCallBack(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(Cursor cursor)
{
if (this.InvokeRequired()) {
SetCursorCallBack callBack = new SetCursorCallBack(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_SomeEventFiredFromAnotherThread(
object sender,
EventArgs e
)
{
SetCursor(Cursors.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