public static void Start() { if (_studentMapping == null) { _studentMapping = new StudentMapping(); _studentMapping._task = _studentMapping.processStudentMappingsAsync(); } }
public static void Stop() { if (_studentMapping != null) { if (_studentMapping._task.Status == TaskStatus.Running && !_studentMapping._task.Wait(TimeSpan.FromSeconds(100))) ErrorLog.Write("Failed to stop student mapping process"); _studentMapping = null; } }
protected override void OnStop() { try { Service.IsStopping = true; StudentMapping.Stop(); //UploadedFileParser.Stop(); } catch { //TODO: Log the error } }
protected override void OnStart(string[] args) { Task.Run(() => { try { Service.IsStopping = false; StudentMapping.Start(); //UploadedFileParser.Start(); } catch (Exception ex) { // stop the service ErrorLog.Write(ex); base.Stop(); } }); }