/// <summary> /// Enqueues a unit of work /// </summary> /// <param name="work">The work to be performed</param> /// <param name="worker">The handler that will be invoked to perform the work</param> /// <param name="observers">A listener for which appropriate actions will be invoked during /// execution</param> /// <returns></returns> public WorkPartition Submit(IPartitionedWork work, Action <IPartitionedWork> worker, IReadOnlyList <IWorkAgentObserver> observers) { var clrTaskId = WorkPartition.AssignIdentity(); Action <IPartitionedWork> adapter = w => { iter(observers, observer => observer.RaiseWorkDispatched(work)); try { worker(work); } finally { HandleTaskCompletion(clrTaskId).OnNone(() => Notify(AppMessage.Warn("There was no task to complete"))); } iter(observers, observer => observer.RaiseWorkCompleted(work)); }; var workTask = EnqueueWork(WorkPartition.Create(clrTaskId, work, adapter)); iter(observers, observer => observer.RaiseWorkSubmitted(work)); return(workTask); }
/// <summary> /// Defines a correlated warning /// </summary> /// <param name="CT">The correlation value</param> /// <param name="text">The message text</param> /// <param name="callerFile">The file from which the call was made</param> /// <param name="callerName">The name of the invoking member</param> /// <returns></returns> public static IAppMessage warn(CorrelationToken CT, string text, [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null) => AppMessage.Warn(text, callerFile, callerName);
/// <summary> /// Defines a correlated warning with typed content /// </summary> /// <typeparam name="C">The content type</typeparam> /// <param name="CT">The correlation value</param> /// <param name="template">A content-bound template string</param> /// <param name="content">The typed content</param> /// <param name="callerFile">The file from which the call was made</param> /// <param name="callerName">The name of the invoking member</param> /// <returns></returns> public static IAppMessage warn <C>(CorrelationToken CT, string template, C content, [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null) => AppMessage.Warn(CT, template, content, callerFile, callerName);
static IAppMessage EmptyWorker() => AppMessage.Warn("I do nothing");
public static IAppMessage AlreadyRunning() => AppMessage.Warn("The agent is already running");
public static IAppMessage TasksUnfinished(int Count, int Timeout) => AppMessage.Warn("There were @Count currentingly executing tasks when a wait timeout of @Timeout ms expired", new { Count, Timeout });
public static IAppMessage EnqueuedNewCommands(CommandSpecDescriptor d, int Count) => AppMessage.Warn("Enqueued @Count new @CommandName commands", new { d.CommandName, Count });
public static IAppMessage OrchestratedTasksStillExecuting(CommandSpecDescriptor d) => AppMessage.Warn("@CommandName commands are still executing", new { d.CommandName });