public static Task <SchedueledItem> ProcessCheck(SchedueledItem workItem)
 {
     return(Task.Factory.StartNew(() =>
     {
         workItem.Execute();
         return workItem;
     }));
 }
        void LocalCheckSchedulerTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!SheduledItems.Any())
            {
                return;
            }

            var itemsToProcess = SheduledItems.Where(x => x.Value.NextRunTime < DateTime.Now).ToList();

            foreach (var schedueleItem in itemsToProcess.ToList())
            {
                SchedueledItem workItem = null;
                if (SheduledItems.TryRemove(schedueleItem.Key, out workItem))
                {
                    var processCheck = ProcessCheck(workItem);
                    processCheck.ContinueWith(ReAddWorkItemAfterCompletion);
                }
            }
        }
 public static Task<SchedueledItem> ProcessCheck(SchedueledItem workItem)
 {
     return Task.Factory.StartNew(() =>
     {
         workItem.Execute();
         return workItem;
     });
 }