I'm developing a class library in .NET that other developers will consume eventually. This library makes use of a few worker threads, and those threads fire status events that will cause some UI controls to be updated in the WinForms / WPF application.
Normally, for every update, you would need to check the .InvokeRequired property on WinForms or equivalent WPF property and invoke this on the main UI thread for updating. This can get old quickly, and something doesn't feel right about making the end developer do this, so...
Is there any way that my library can fire/invoke the events/delegates from the main UI thread?
In particular...
- Should I automatically "detect" the "main" thread to use?
- If not, should I require the end developer to call some (pseudo)
UseThisThreadForEvents()
method when the application starts so I can grab the target thread from that call?