Beispiel #1
0
 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();
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public static void Init()
 {
     SingleThreadStarter.ValidateThreadStates();
 }
Beispiel #4
0
 private void OnApplicationQuit()
 {
     SingleThreadStarter.AbortRunningThreads();
 }