コード例 #1
0
        public static RunTask Start(Action action, int delay)
        {
            var run = new RunTask();
            var task = Task.Delay(delay, run.GetToken());
            task.ContinueWith(t =>
            {
                try
                {
                    run.GetToken().ThrowIfCancellationRequested();
                    action();
                }
                catch (Exception)
                {
                }
            });

            return run;
        }
コード例 #2
0
        public static RunTask Start(Action action, int delay)
        {
            var run  = new RunTask();
            var task = Task.Delay(delay, run.GetToken());

            task.ContinueWith(t =>
            {
                try
                {
                    run.GetToken().ThrowIfCancellationRequested();
                    action();
                }
                catch (Exception)
                {
                }
            });

            return(run);
        }