First of all, is it 'legal' (i.e. thread-safe) to pass events back from
a worker thread to the main thread? I.E. Can one put PUBLIC EVENT XYZ
in their worker thread and then raise that event for processing back in
the main thread? I believe this is OK, but I want to check first...
Secondly, if this is 'legal', what happens in the following scenario:
Lets say that in my main (Win Form) program/thread I spawn two worker
threads. Thread one does some work then raises the 'ImAlmostDone' event
back to my main thread. Now, at about the same time, my second thread
also raises a 'ImAlmostDone' event back. In this case, do both events
get processed in the main thread? And do they get processed in the
proper order - i.e. thread 1's event, then thread 2. Or do I need to do
any thread locking before I process the event (i.e. to make sure the
main thread finishes the event before the next thread raises the same
event)
Before I start passing events back, I want to make sure this is going
to work and I am not going to screw things up.
Thanks in advance.
Tom