Problem statement
I have a worker thread that basically scans a folder, going into the files within it, and then sleeps for a while. The scanning operat
Another alternative is to use events:
private ManualResetEvent _event = new ManualResetEvent(false); public void Run() { while (true) { DoSomethingThatTakesSeveralSeconds(); if (_event.WaitOne(timeout)) break; } } public void Stop() { _event.Set(); thread.Join(); }