public static ThreadStarter StartImmediate(Action action, string threadName) { var thread = new ThreadStarter(action, threadName); thread.Start(); return(thread); }
/// <summary> /// Add's a <c>ThreadStarter</c> element to the internal thread list /// </summary> /// <remarks> /// Raises the <see cref="ThreadAdded" /> event. /// </remarks> /// <param name="thread">The ThreadStarter element to add</param> private static void RegisterThread(ThreadStarter thread) { Threads.Add(thread); if (ThreadAdded != null) { ThreadAdded(null, thread); } }
/// <summary> /// Remove a ThreadStarter element from the internal thread list /// </summary> /// <remarks> /// Raises the <see cref="ThreadRemoved" /> event. /// </remarks> /// <param name="thread">The ThreadStarter element to remove</param> private static void UnregisterThread(ThreadStarter thread) { try { Threads.Remove(thread); } catch (ArgumentOutOfRangeException e) { TraceHelper.TraceError(string.Format("ThreadStarter.UnregisterThread encountered an exception: {0}", e.Message)); } finally { if (ThreadRemoved != null) { ThreadRemoved(null, thread); } } }