public void StopPlugin() { Log.Info("StopPlugin"); Status = StatusEnum.Stopping; _cancellationTokenSource.Cancel(); if (_taskManager != null) { _taskManager.ShutDown(); _taskManager = null; } if (_queuesManager != null) { _queuesManager.ShutDown(); _queuesManager = null; } if (_octaneApis != null) { _octaneApis.ShutDown(); _octaneApis = null; } _octaneInitializationThread = null; Status = StatusEnum.Stopped; Log.Info("StopPlugin Done"); }
private void StopAllThreads() { _cancellationTokenSource.Cancel(); if (_queuesManager != null) { _queuesManager.ShutDown(); } if (_taskManager != null) { _taskManager.ShutDown(); } }
private void StartPluginInternal(CancellationToken token) { Status = StatusEnum.Connecting; while (Status != StatusEnum.Connected && !token.IsCancellationRequested) { try { TfsApis tfsApis = ConnectionCreator.CreateTfsConnection(_connectionDetails); OctaneApis octaneApis = ConnectionCreator.CreateOctaneConnection(_connectionDetails); _taskManager = new OctaneTaskManager(tfsApis, octaneApis); _taskManager.Start(); _queuesManager = new QueuesManager(tfsApis, octaneApis); _queuesManager.Start(); _initFailCounter = 0; Status = StatusEnum.Connected; } catch (Exception ex) { Log.Error($"Error in StartPlugin : {ex.Message}", ex); if (_queuesManager != null) { _queuesManager.ShutDown(); _queuesManager = null; } if (_taskManager != null) { _taskManager.ShutDown(); _taskManager = null; } } //Sleep till next retry if (Status != StatusEnum.Connected) { int initTimeoutIndex = Math.Min((_initFailCounter / 3), _initTimeoutInMinutesArr.Length - 1); int initTimeoutMinutes = _initTimeoutInMinutesArr[initTimeoutIndex]; Log.Info($"Wait {initTimeoutMinutes} minute(s) till next initialization attempt..."); Thread.Sleep(initTimeoutMinutes * 1000 * 60); _initFailCounter++; } } }