public ThreadWaitForNextFrame(int waitFrames = 1, int sleepTime = 5)
        {
            bool flag = waitFrames > 0;

            if (flag)
            {
                bool flag2 = MainThreadWatchdog.CheckIfMainThread();
                if (flag2)
                {
                    Debug.Log("Its not allowed to put the MainThread to sleep!");
                }
                else
                {
                    int  currentFrame = MainThreadDispatcher.currentFrame;
                    bool flag3        = !UnityActivityWatchdog.CheckUnityRunning();
                    if (!flag3)
                    {
                        Thread.Sleep(sleepTime);
                        while (!UnityActivityWatchdog.CheckUnityActive() || currentFrame + waitFrames >= MainThreadDispatcher.currentFrame)
                        {
                            Thread.Sleep(sleepTime);
                        }
                    }
                }
            }
        }
        public ThreadWaitForSeconds(float seconds)
        {
            if (MainThreadWatchdog.CheckIfMainThread())
            {
                Debug.Log("Its not allowed to put the MainThread to sleep!");
                return;
            }
			
			if(!UnityActivityWatchdog.CheckUnityRunning())
				return;

            Thread.Sleep((int)Mathf.Max( 1, Mathf.Round(seconds * 1000f)));
            while (!UnityActivityWatchdog.CheckUnityActive())
                Thread.Sleep(5);
        }
Esempio n. 3
0
        public ThreadWaitForNextFrame(int waitFrames = 1, int sleepTime = 5)
        {
            if (waitFrames > 0)
            {
                if (MainThreadWatchdog.CheckIfMainThread())
                {
                    Debug.Log("Its not allowed to put the MainThread to sleep!");
                    return;
                }

                int startFrame = MainThreadDispatcher.currentFrame;
                Thread.Sleep(sleepTime);

                while (!UnityActivityWatchdog.CheckUnityActive() || startFrame + waitFrames >= MainThreadDispatcher.currentFrame)
                {
                    Thread.Sleep(sleepTime);
                }
            }
        }
        public ThreadWaitForSeconds(float seconds)
        {
            bool flag = MainThreadWatchdog.CheckIfMainThread();

            if (flag)
            {
                Debug.Log("Its not allowed to put the MainThread to sleep!");
            }
            else
            {
                bool flag2 = !UnityActivityWatchdog.CheckUnityRunning();
                if (!flag2)
                {
                    Thread.Sleep((int)Mathf.Max(1f, Mathf.Round(seconds * 1000f)));
                    while (!UnityActivityWatchdog.CheckUnityActive())
                    {
                        Thread.Sleep(5);
                    }
                }
            }
        }