protected void CleanUp(string testFolder = DefaultRuntimeFolder) { Console.WriteLine("Cleaning up test."); if (TimerTask != null) { TestTimer.Stop(); TimerTask.Dispose(); TimerTask = null; } // Wait for file upload task to complete Thread.Sleep(500); string dir = Path.Combine(Directory.GetCurrentDirectory(), testFolder); try { if (Directory.Exists(dir)) { Directory.Delete(dir, true); } } catch (IOException) { // do not fail if clean up is unsuccessful } }
/// <inheritdoc /> public void Stop() { _logger.Information("Message Bus stopping"); try { _messageBroker.SendMessageBusHandshake(Enumerable.Empty <Shared.Messages.SubscribeHandler>(), Enumerable.Empty <Shared.Messages.RequestHandler>(), _cancellationTokenSource.Token); } catch (Exception exception) { _logger.Error(exception, "Unable to send empty handshake to broker"); } _cancellationTokenSource?.Cancel(); _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; _handshakeTask?.Dispose(); Parallel.ForEach(_subscribeHandlers, subscribeHandler => subscribeHandler.Stop()); Parallel.ForEach(_requestHandlers, requestHandler => requestHandler.Stop()); _cancellationTokenRegistration.Dispose(); _logger.Information("Message Bus stopped"); }
protected void CleanUp(string testFolder = DefaultRuntimeFolder) { Logger.Log(Level.Verbose, "Cleaning up test."); if (_enableRealtimeLogUpload) { if (TimerTask != null) { TestTimer.Stop(); TimerTask.Dispose(); TimerTask = null; } // Wait for file upload task to complete Thread.Sleep(500); } string dir = Path.Combine(Directory.GetCurrentDirectory(), testFolder); try { if (Directory.Exists(dir)) { Directory.Delete(dir, true); } } catch (IOException) { // do not fail if clean up is unsuccessful } catch (UnauthorizedAccessException) { // do not fail if clean up is unsuccessful } }
protected void debugTimerTestThread() { // create set (timer task). initially empty TimerTask timerTask = new TimerTask("ShortTimers"); Console.WriteLine("Start timers " + DateTime.Now); // create two types of timers TimerList timers_5sec = new TimerList("5sec", 5 * 1000, 100, this.Timer5sHandler, timerTask); TimerList timers_30sec = new TimerList("30sec", 30 * 1000, 100, this.Timer30sHandler, timerTask); timerTask.Start(); // start some timers timers_5sec.Start(); timers_5sec.Start(); timers_5sec.Start(); Thread.Sleep(1 * 1000); timers_5sec.Start(); ITimer timer; long timerId; timers_30sec.Start(out timer, out timerId, null, false); timers_5sec.Start(); debugTimerShowCallback(null, null, null); // wait for the first timer to expire Thread.Sleep(10 * 1000); timers_30sec.Stop(timer, timerId); Thread.Sleep(30 * 1000); debugTimerShowCallback(null, null, null); // clean up timers_5sec.Dispose(); timers_30sec.Dispose(); timerTask.Dispose(); }