public CustomTaskManager(bool removeWhenComplete = false, [CallerMemberName] string callerName = "") { RemoveWhenComplete = removeWhenComplete; CallerName = callerName; Log.Debug($"{CallerName} waiting on lock. taskmonitor status: {_taskMonitor.Status}", ConsoleColor.White); lock (_taskMonLock) { Log.Debug($"{CallerName} in lock. taskmonitor status: {_taskMonitor.Status}", ConsoleColor.White); if (!_isRunning && _taskMonitor.Status == TaskStatus.Created) { _isRunning = true; Log.Highlight($"{CallerName} starting taskmonitor. status: {_taskMonitor.Status}", ConsoleColor.White); _instance = Instance.Singleton(); Config = _instance.Config; _customScheduler = new CustomTaskScheduler(Config); _taskMonitor.Start(); Log.Highlight($"{CallerName} started taskmonitor. status: {_taskMonitor.Status}", ConsoleColor.White); } if (_taskMonitor.Status != TaskStatus.RanToCompletion) { Log.Info($"{CallerName} adding task instance. taskmonitor status: {_taskMonitor.Status}", ConsoleColor.White); _allInstances.Add(this); } else { Log.Error("taskmonitor already completed. not adding task"); } } }
public CustomTaskManager(bool removeWhenComplete = false, [CallerMemberName] string callerName = "") { RemoveWhenComplete = removeWhenComplete; CallerName = callerName; lock (_taskMonitor) { if (_taskMonitor.Status == TaskStatus.Created) { _taskMonitor.Start(); _customScheduler = new CustomTaskScheduler(Config); Log.Info($"starting taskmonitor. status: {_taskMonitor.Status}", ConsoleColor.White); } } Log.Info($"adding task instance for:{CallerName} taskmonitor status: {_taskMonitor.Status}", ConsoleColor.White); _allInstances.Add(this); }