public static void AbortRunningThreads() { SingleThreadStarter.ValidateThreadStates(); Debug.Log("Abort running Threads: " + SingleThreadStarter.startedThreads.Count); foreach (Thread current in SingleThreadStarter.startedThreads) { current.Interrupt(); current.Join(100); } SingleThreadStarter.startedThreads.Clear(); }
public static Thread StartSingleThread(ParameterizedThreadStart targetMethod, object argument, System.Threading.ThreadPriority priority = System.Threading.ThreadPriority.Normal, bool safeMode = true) { SingleThreadStarter.Init(); MainThreadWatchdog.Init(); MainThreadDispatcher.Init(); UnityActivityWatchdog.Init(); Thread thread; if (safeMode) { SingleThreadStarter.SafeSingleThreadSession @object = new SingleThreadStarter.SafeSingleThreadSession(targetMethod); thread = new Thread(new ParameterizedThreadStart(@object.SafeExecte_ParamThreadStart)); } else { thread = new Thread(targetMethod); } thread.Priority = priority; SingleThreadStarter.startedThreads.Add(thread); thread.Start(argument); return(thread); }
public static void Init() { SingleThreadStarter.ValidateThreadStates(); }
private void OnApplicationQuit() { SingleThreadStarter.AbortRunningThreads(); }