public void registerService(JService service) { lock (this) { service.Id = idCounter++; } ServiceList.Add(service.Id, service); }
//Aborts thread without giving it chance to finish public void forceStopService(JService service) { Thread threadToEnd; try { ThreadList.TryGetValue(service.Id, out threadToEnd); threadToEnd.Abort(); removeService(service); } catch (ArgumentNullException e) { Console.WriteLine("Force Stop " + service.Id + " Failed: " + e.ToString()); } }
public bool startService(JService service) { JService serviceToStart; Thread threadStarted; try { ServiceList.TryGetValue(service.Id, out serviceToStart); threadStarted = new Thread(service.start); ThreadList.Add(service.Id, threadStarted); threadStarted.Start(); return(true); } catch (ArgumentNullException e) { Console.WriteLine("Start Service " + service.Id + " Failed: " + e.ToString()); } return(false); }
public void removeService(JService service) { ThreadList.Remove(service.Id); ServiceList.Remove(service.Id); }