/// <summary> /// Clean up all of the background threads when the pool is destroyed /// </summary> protected override void DisposeOfManagedResources() { // dispose of the processing thread _processingThread.Dispose(); _processingThread = null; // dispose of all of the thread pool threads this.DestroyThreads(false /* all threads */); }
/// <summary> /// Destroys the specified thread /// </summary> /// <param name="thread"></param> /// <param name="force"></param> private void DestroyThread(BackgroundThread thread, bool force) { try { if (thread != null) { if (thread.IsFinished || force) { thread.Dispose(); } } } catch (ThreadAbortException) { } catch (Exception ex) { Log.WriteLine(ex); } }
/// <summary> /// Destroys the specified thread /// </summary> /// <param name="thread"></param> /// <param name="force"></param> private void DestroyThread(BackgroundThread thread, bool force) { try { if (thread != null) if (thread.IsFinished || force) thread.Dispose(); } catch(ThreadAbortException) { } catch(Exception ex) { Log.WriteLine(ex); } }