A
Alphamacaroon
All,
I have a quick question regarding events and UI threads. I'm developing
an API (simple C# class with no UI) which I want to be able to give to
other developers to develop their own UI's around. This API has a
number of events which UI developers will want to hook into to be able
to update their UI accordingly. However, many of these events will be
thrown from multiple threads spawned from within the API. My questions
are:
1) Since the events are thrown from threads within the API, the event
handler in the UI application is occuring on the API thread and not the
UI thread right? If this is right, then I know that this is a no-no and
the UI developer will have to call Form.BeginInvoke to marshall any
code back to the UI thread.
2) (Assuming I'm right above) Is there any way to find the UI thread
and marshall the event into it before the event is thrown so that the
UI developer doesn't have to worry about, or remember to use
Begin.Invoke?
At the end of the day I don't want to assume that my UI developers are
going to remember to call Form.BeginInvoke in these events.
Any help would be greatly appreciated!
I have a quick question regarding events and UI threads. I'm developing
an API (simple C# class with no UI) which I want to be able to give to
other developers to develop their own UI's around. This API has a
number of events which UI developers will want to hook into to be able
to update their UI accordingly. However, many of these events will be
thrown from multiple threads spawned from within the API. My questions
are:
1) Since the events are thrown from threads within the API, the event
handler in the UI application is occuring on the API thread and not the
UI thread right? If this is right, then I know that this is a no-no and
the UI developer will have to call Form.BeginInvoke to marshall any
code back to the UI thread.
2) (Assuming I'm right above) Is there any way to find the UI thread
and marshall the event into it before the event is thrown so that the
UI developer doesn't have to worry about, or remember to use
Begin.Invoke?
At the end of the day I don't want to assume that my UI developers are
going to remember to call Form.BeginInvoke in these events.
Any help would be greatly appreciated!