Aegis.Threading.NamedThread.Abort C# (CSharp) Method

Abort() public method

public Abort ( int millisecondsTimeout = 1000 ) : void
millisecondsTimeout int
return void
        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)
            {
            }
        }

Same methods

NamedThread::Abort ( string name, int millisecondsTimeout = 1000 ) : void

Usage Example

Example #1
0
        public static void Abort(string name, int millisecondsTimeout = 1000)
        {
            lock (Threads)
            {
                NamedThread namedThread = Threads[name];
                if (namedThread == null)
                {
                    return;
                }

                namedThread.Abort(millisecondsTimeout);
            }
        }