I have a loop like below
for(int i = 0; i < 10; i++)
{
// some long time processing
}
I want to create a timer, which would check if one processing runs more than 5 minutes. If one processing runs more than 5 minutes, it would stop current processing then start another processing.
Is it possible to make another thread to monitor the main loop?
My program is a console application.
Take a look at ManualResetEvent and specifically the WaitOne method.
In addition to Jamie's asnwer you can use the System.Threading.Timer, which will execute in a background thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With