public void Stop() { if (_status == RunnableStatus.Stopped) { return; } try { _status = RunnableStatus.Stopping; lock (this) { OnStop(); } } finally { _status = RunnableStatus.Stopped; } }
public void Start(object context = null) { if (_status == RunnableStatus.Running) { return; } try { _status = RunnableStatus.Running; lock (this) { OnStart(context); } } catch (Exception) { Stop(); throw; } }