public void Abort(int millisecondsTimeout = 1000) { try { _cts.Cancel(); if (_thread.Join(millisecondsTimeout) == false) _thread.Abort(); lock (Threads) Threads.Remove(Name); _cts.Dispose(); _cts = null; _thread = null; } catch (Exception) { } }
public static void Abort(string name, int millisecondsTimeout = 1000) { lock (Threads) { NamedThread namedThread = Threads[name]; if (namedThread == null) { return; } namedThread.Abort(millisecondsTimeout); } }