Beispiel #1
0
    private void Stop()
    {
        if (WorkerSettings.Multithreaded)
        {
            // Signal the thread to stop
            StopSignal.Set();

            // Wait ten seconds for the thread to finish
            ExitedSignal.WaitOne(10 * 1000);

            // Reset the stop and exited flags so that the thread can be restarted
            StopSignal.Reset();
            ExitedSignal.Reset();
        }
        else
        {
            ThreadTeardown();
        }
    }
Beispiel #2
0
    private void Run()
    {
        try
        {
            bool receivedStopSignal = false;

            ThreadSetup();

            //Initial wait before starting.
            Thread.Sleep(30);

            while (!receivedStopSignal)
            {
                ThreadUpdate();

                // See if the main thread signaled us to stop
                if (StopSignal.WaitOne(0))
                {
                    receivedStopSignal = true;
                }

                if (!receivedStopSignal)
                {
                    System.Threading.Thread.Sleep(1);
                }
            }

            ThreadTeardown();
        }
        catch (Exception e)
        {
            UnityEngine.Debug.LogError(string.Format("PSMoveWorker: WorkerThread crashed: {0}", e.Message));
            UnityEngine.Debug.LogException(e);
        }
        finally
        {
            ExitedSignal.Set();
        }
    }