internal static Task QueueNamedTask(this OrleansTaskScheduler scheduler, Func <Task> taskFunc, ISchedulingContext targetContext, string activityName = null) { var workItem = new AsyncClosureWorkItem(taskFunc, activityName); scheduler.QueueWorkItem(workItem, targetContext); return(workItem.Task); }
internal static Task <T> QueueTask <T>(this OrleansTaskScheduler scheduler, Func <Task <T> > taskFunc, ISchedulingContext targetContext) { var workItem = new AsyncClosureWorkItem <T>(taskFunc); scheduler.QueueWorkItem(workItem, targetContext); return(workItem.Task); }
internal static Task QueueTask(this OrleansTaskScheduler scheduler, Func <Task> taskFunc, IGrainContext targetContext) { var workItem = new AsyncClosureWorkItem(taskFunc, targetContext); scheduler.QueueWorkItem(workItem); return(workItem.Task); }
private static Task QueueNamedTask(this IWorkItemScheduler scheduler, Func <Task> taskFunc, IGrainContext targetContext, string activityName = null) { var workItem = new AsyncClosureWorkItem(taskFunc, activityName, targetContext); scheduler.QueueWorkItem(workItem); return(workItem.Task); }
internal static Task QueueTask(this IGrainContext targetContext, Func <Task> taskFunc) { var workItem = new AsyncClosureWorkItem(taskFunc, targetContext); targetContext.Scheduler.QueueWorkItem(workItem); return(workItem.Task); }
internal static Task RunOrQueueTask(this IGrainContext targetContext, Func <Task> taskFunc) { var currentContext = RuntimeContext.Current; if (currentContext != null && currentContext.Equals(targetContext)) { try { return(taskFunc()); } catch (Exception exc) { return(Task.FromResult(exc)); } } var workItem = new AsyncClosureWorkItem(taskFunc, targetContext); targetContext.Scheduler.QueueWorkItem(workItem); return(workItem.Task); }
private static Task <T> RunOrQueueTask <T>(this IWorkItemScheduler scheduler, Func <Task <T> > taskFunc, IGrainContext targetContext) { var currentContext = RuntimeContext.Current; if (currentContext is object && currentContext.Equals(targetContext)) { try { return(taskFunc()); } catch (Exception exc) { var resolver = new TaskCompletionSource <T>(TaskCreationOptions.RunContinuationsAsynchronously); resolver.TrySetException(exc); return(resolver.Task); } } var workItem = new AsyncClosureWorkItem <T>(taskFunc, targetContext); scheduler.QueueWorkItem(workItem); return(workItem.Task); }