public void QueueInvocation() { var operation = new RelayOperation(new Action(ExecuteActionAfterDelay)); operation.DispatchMode = OperationDispatchMode.ThreadPoolUserWorkItem; operation.Run(); }
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(); }