Delay() public static method

public static Delay ( int millisecondTimeout ) : System.Threading.Tasks.Task
millisecondTimeout int
return System.Threading.Tasks.Task
Ejemplo n.º 1
0
        void BackgroundToBackgroundException()
        {
            var task1 = UnityTask.Run(() =>
            {
                Debug.Log("1 Go");

                var task2 = UnityTask.Run(() =>
                {
                    UnityTask.Delay(100);
                    Debug.Log("2 Go");
                    throw new Exception("2 Fail");
                });

                task2.Wait();

                if (task2.IsFaulted)
                {
                    throw task2.Exception;
                }
            });

            task1.Wait();

            Debug.Log(task1.Status + " " + task1.Exception.Message);
        }
Ejemplo n.º 2
0
 void Background()
 {
     UnityTask.Run(() =>
     {
         Debug.Log("Sleeping...");
         UnityTask.Delay(2000);
         Debug.Log("Slept");
     });
 }
Ejemplo n.º 3
0
 void MainTest()
 {
     UnityTask.RunOnMain(() =>
     {
         Debug.Log("Sleeping...");
         UnityTask.Delay(2000);
         Debug.Log("Slept");
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Waits for the task to complete
        /// </summary>
        public static T Wait <T>(this T self) where T : UnityTask
        {
            UnityTask.Delay(10);

            while (self.keepWaiting)
            {
                UnityTask.Delay(10);
            }

            return(self);
        }
Ejemplo n.º 5
0
        void BackgroundToRotine()
        {
            UnityTask.Run(() =>
            {
                Debug.Log("Thread A Running");

                var task = UnityTask.RunCoroutine(RoutineFunction());

                while (task.IsRunning)
                {
                    Debug.Log(".");
                    UnityTask.Delay(500);
                }

                Debug.Log("Thread A Done");
            });
        }
Ejemplo n.º 6
0
        void BackgroundToMain()
        {
            UnityTask.Run(() =>
            {
                Debug.Log("Thread A Running");

                var task = UnityTask.RunOnMain(() =>
                {
                    Debug.Log("Sleeping...");
                    UnityTask.Delay(2000);
                    Debug.Log("Slept");
                });

                while (task.IsRunning)
                {
                    Debug.Log(".");
                    UnityTask.Delay(100);
                }

                Debug.Log("Thread A Done");
            });
        }