예제 #1
0
        public void QueueInvocation()
        {
            var operation = new RelayOperation(new Action(ExecuteActionAfterDelay));

            operation.DispatchMode = OperationDispatchMode.ThreadPoolUserWorkItem;
            operation.Run();
        }
예제 #2
0
        public static void ExecuteDelayed([NotNull] this Action action, TimeSpan delay)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var operation = new RelayOperation(() =>
            {
                Thread.Sleep(delay);
                action();
            });

            operation.DispatchMode = OperationDispatchMode.ThreadPoolUserWorkItem;
            operation.Run();
        }