Exemple #1
0
 void OnProcessExited(Context context, ProcessInstance instance)
 {
     PostTask(
         "Exited process",
             () =>
             {
                 Context currentContext;
                 if (_contexts.TryGetValue(context.Definition.Name, out currentContext) &&
                     ReferenceEquals(currentContext, context) &&
                     ReferenceEquals(currentContext.Instance, instance))
                 {
                     currentContext.Instance = null;
                     StartProcess(currentContext.Definition.Name);
                 }
             }
         );
 }
Exemple #2
0
        public Task StartProcess(string processName)
        {
            return PostTask(
                "Start process",
                () =>
                {
                    Context context;
                    if (!_contexts.TryGetValue(processName, out context))
                    {
                        throw new Exception("Process name not present");
                    }
                    var instance = new ProcessInstance(_loggerFactory, context.Definition);
                    instance.Exited.ContinueWith(_ => OnProcessExited(context, instance));

                    context.Instance = instance;
                    context.Instance.Execute();
                });
        }