private Thread m_trd = null; private void RunLongProcess() { AbortThread(); m_trd = new Thread(new ThreadStart(this.LongProcess)); m_trd.IsBackground = true; m_trd.Start(); } private void LongProcess() { } private void AbortThread() { if (m_trd != null) { if (m_trd.IsAlive) { m_trd.Abort(); Sayuser("Aborted"); } else Sayuser("Thread had completed"); m_trd = null; } else Sayuser("No thread to abort"); }
This layout has been adapted from an original design by Ruthsarian Layouts, downloaded from oswd.org