public static void ShutDown(RemainingTime remainingTime, params IShutDownable[] shutDownables) { if (shutDownables == null) { return; } foreach (var shutDownable in shutDownables) { if (shutDownable != null) { shutDownable.SignalShutDown(); } } foreach (var shutDownable in shutDownables) { if (shutDownable != null) { try { shutDownable.ShutDown(remainingTime); } catch (Exception exc) { Log.Exception("Failed to shutdown: {0}", exc); } } } }
public void ShutDown(RemainingTime remainingTime) { var thread = Interlocked.Exchange(ref m_executingThread, null); if (thread != null) { try { SignalShutDown(); var joinTimeOut = (int)remainingTime.Remaining.TotalMilliseconds / 2; if (!thread.Join(joinTimeOut)) { Log.Warning( "SequentialTaskScheduler.Dispose: {0} - Executing thread didn't shutdown, aborting it...", Name ); thread.Abort(); var abortTimeOut = remainingTime.Remaining; if (!thread.Join(abortTimeOut)) { Log.Warning( "SequentialTaskScheduler.Dispose: {0} - Executing thread didn't shutdown after abort, ignoring it...", Name ); } } } catch (Exception exc) { Log.Exception( "SequentialTaskScheduler.Dispose: {0} - Caught exception: {1}", Name, exc ); } } }