private static void ThreadShutDownRequested(object sender, WorkerThreadEventArgs args) { if (IsDebugEnabled) { log.Debug(((AbstractThread)sender).Name + " is shutdown...."); } ThreadTool.Sleep(0); }
private static void ThreadThreadFinished(object sender, WorkerThreadEventArgs args) { if (IsDebugEnabled) { log.Debug(((AbstractThread)sender).Name + " is finished."); } ThreadTool.Sleep(0); }
public void SleepPerfCounterTest() { using (new OperationTimer("AbstractThread")) { try { ThreadTool.Sleep(MillisecondsTimeout); } catch (ThreadInterruptedException tie) { if (log.IsWarnEnabled) { log.WarnException("Thread.Sleep 중에 Interrupted 되었습니다.", tie); } } } }
public void CountUpThreadTest() { if (log.IsInfoEnabled) { log.Info("main : BEGIN"); } try { var thread = new CountUpThread("Counter Thread"); thread.ThreadStarted += ThreadThreadStarted; thread.ThreadFinished += ThreadThreadFinished; thread.ShutDownRequested += ThreadShutDownRequested; thread.ThreadProgressChanged += ThreadThreadProgressChanged; thread.Start(); ThreadTool.Sleep(5000); if (log.IsInfoEnabled) { log.Info("main : Call ShutDown() "); } thread.ShutDown(); if (log.IsInfoEnabled) { log.Info("main : Call Join() "); } thread.Join(); Assert.IsFalse(thread.IsAlive); } catch (ThreadInterruptedException) { if (IsDebugEnabled) { log.Debug("스레드가 Interrupt되었습니다."); } } if (log.IsInfoEnabled) { log.Info("main : END"); } }
public void SleepTest() { var stopwatch = new Stopwatch(); stopwatch.Start(); try { ThreadTool.Sleep(MillisecondsTimeout); } catch (ThreadInterruptedException ex) { if (log.IsWarnEnabled) { log.WarnException("쓰레드가 중단되었습니다.", ex); } } stopwatch.Stop(); var ts = stopwatch.Elapsed; if (IsDebugEnabled) { log.Debug("AbstractThread.Sleep({0}) ==> {1} msec by DateTime", (object)MillisecondsTimeout, (object)ts.TotalMilliseconds); } }