I have a pretty good multi-threaded winforms application that uses EventWaitHandle in several places to synchronize access.
So, I have code similar to this:
List<int> _revTypes;
EventWaitHandle _ewh = new EventWaitHandle(false, EventResetMode.ManualReset);
void StartBackgroundTask() {
_ewh.Reset();
Thread t = new Thread(new ThreadStart(LoadStuff));
t.Start();
}
void LoadStuff() {
_revTypes = WebServiceCall.GetRevTypes()
_ewh.Set();
}
List<int> RevTypes {
get {
_ewh.WaitOne();
return _revTypes;
}
}
Then I just call .RevTypessomeehre from the user interface and it will return the data to me when it LoadStuffcompletes.
All this works perfectly correctly, however RevTypes- this is just one property - in fact there are several dozen of them. And one or more of these properties quickly support the user interface.
, , ? , EventWaitHandle ?