Beispiel #1
0
        public void Stop()
        {
            const int thread_join_timeout = 30000;

            Threads.ForEach(t => t.Exit());
            Threads.Where(t => t.Running).ForEach(t =>
            {
                var thread = t.Thread;

                if (thread == null)
                {
                    // has already been cleaned up (or never started)
                    return;
                }

                if (!thread.Join(thread_join_timeout))
                {
                    Logger.Log($"Thread {t.Name} failed to exit in allocated time ({thread_join_timeout}ms).", LoggingTarget.Runtime, LogLevel.Important);
                }
            });

            // as the input thread isn't actually handled by a thread, the above join does not necessarily mean it has been completed to an exiting state.
            while (!mainThread.Exited)
            {
                mainThread.ProcessFrame();
            }

            ThreadSafety.ResetAllForCurrentThread();
        }
Beispiel #2
0
 public void Stop()
 {
     Threads.ForEach(thread => thread.Stop());
     this.Stopped = true;
 }
Beispiel #3
0
 public void Restart()
 {
     this.Stopped = false;
     Threads.ForEach(thread => thread.EnsureAlive());
 }
Beispiel #4
0
 public void EnsureAlive()
 {
     Threads.ForEach(thread => thread.EnsureAlive());
 }