/// <summary> /// stopps the waiting thread, no action will be performed /// </summary> public void Stop() { _state = TimeBuffStatus.Stopped; }
private void CreateRunnerThread() { _runnerThread = new Thread((ThreadStart) delegate { _state = TimeBuffStatus.Waiting; while (_state != TimeBuffStatus.Stopped) { //if the time for doing the action has come (or passed) - do the action if (_when - DateTime.Now < TimeSpan.Zero) { try { _origSyncContext.Send((SendOrPostCallback)delegate { _action.Invoke(ContentObject); }, null); _state = TimeBuffStatus.Done; break; } catch (Exception ex) { _problem = ex; _state = TimeBuffStatus.Error; break; } } Thread.Sleep(100); } }); }