I am planning to use Auto reset Event Handle for Inter Thread communication.
EventWaitHandle handle = new EventWaitHandle(false, EventResetMode.AutoReset);
My producer thread code look like below
produceSomething();
handle.Set();
In the consumer thread, I have to download data for every one minute or when prodcuer is called Set method
try
{
while(true)
{
handle.WaitOne(60000, false);
doSomething(); // Downloads data from Internet.
// Takes lot of time to complete it.
}
}
catch(ThreadAbortException)
{
cleanup();
}
My question is if consumer thread is running doSomething funtion and producer calls set function, what would be state of Auto reset event object?
My requirement is as soon as producer calls set method I have to download fresh data from the Internet. If doSomething function is running, when Producer calls set method, I have to interrupt it and call again.