ChocoPM.Extensions.AsyncExtensions.DelayedExecution C# (CSharp) Method

DelayedExecution() public static method

public static DelayedExecution ( this action, System.TimeSpan delay ) : void
action this
delay System.TimeSpan
return void
        public static void DelayedExecution(this Action action, TimeSpan delay)
        {
            Timer timer = null;
            var context = SynchronizationContext.Current;

            timer = new Timer((c) =>
            {
                timer.Dispose();
                context.Post(spc => action(), null);
            }, null, delay, TimeSpan.FromMilliseconds(-1));
        }
AsyncExtensions