示例#1
0
 // public start/stop methods
 public void Start(TimeSpan waitTimeout)
 {
     if (_state == AsyncClassState.Faulted)
     {
         Logger.LogDebug("Start: Ignoring due to Faulted state!");
         return;
     }
     if (_state != AsyncClassState.Initial)
     {
         throw new InvalidOperationException("Already started!");
     }
     AsyncStart();
     WaitHelper.WaitFor(waitTimeout, () => (_state == AsyncClassState.Running), "Failed to start!");
 }
示例#2
0
 public void Stop(TimeSpan waitTimeout, string reason)
 {
     if (_state == AsyncClassState.Faulted)
     {
         Logger.LogDebug("Stop: Ignoring due to Faulted state!");
         return;
     }
     if (_state != AsyncClassState.Running)
     {
         Logger.LogDebug("Stop: Ignoring due to state is not Running!");
         return;
     }
     AsyncStop(reason);
     WaitHelper.WaitFor(waitTimeout, () => (_state == AsyncClassState.Stopped), "Failed to stop!");
 }