public bool IsAlive(string ID) { if (ID.IsNullOrEmpty() || TDSThreads.IsNullOrEmpty()) { return(false); } try { if (!LockerRun.EnterWait()) { return(true); } var thread = TDSThreads.GetValue(ID); if (thread == null) { return(false); } return(thread.IsAlive); } catch { return(false); } finally { LockerRun.Exit(); } }
public void Terminate(string ID) { if ((TDSThreads == null || !TDSThreads.ContainsKey(ID)) && (TDSTMFlags == null || !TDSTMFlags.ContainsKey(ID))) { return; } if (TDSTMFlags.ContainsKey(ID)) { TDSTMFlags[ID].IsAborting = true; } do { TDSThreads.GetValue(ID).KillInstantly(); /* * try * { * if (TDSThreads.ContainsKey(ID) && TDSThreads[ID] != null && TDSThreads[ID].IsAlive) * { * TDSThreads[ID].Interrupt(); * //TDSThreads[ID].Join(0); * TDSThreads[ID].Abort(); * } * } * catch(Exception ex) * { * Exceptions.Write(ex); * }*/ //TDSThreads.Update(ID, null); //TDSTMFlags.Update(ID, null); TDSThreads.Remove(ID); TDSTMFlags.Remove(ID); Thread.Sleep(1); } while (TDSThreads.ContainsKey(ID) || TDSTMFlags.ContainsKey(ID)); }