Beispiel #1
0
        public void RunInBackground(Step step, string key = null)
        {
            key = step.GetType().GenerateKey(key);

            if (MemoryProcesses.ContainsKey(key))
            {
                FatalException.ArgumentException($"Key already exists for background process : {key}");
            }

            var flow = this.RunWorkflowAsync(step);

            MemoryProcesses.Add(key, flow);
        }
Beispiel #2
0
        public async Task <TFlow> AwaitProcessAsync <TFlow, TStep>(string key = null)
            where TFlow : IWorkflow
            where TStep : Step <TFlow>
        {
            key = typeof(TStep).GenerateKey(key);

            if (MemoryProcesses.TryGetValue(key, out var value))
            {
                return(value is Task <TFlow> task
                    ? await task
                    : throw FatalException.GetFatalException(""));
            }

            throw FatalException.GetFatalException("");;
        }
Beispiel #3
0
        public virtual void Dispose()
        {
            foreach (var(key, process) in MemoryProcesses)
            {
                process.Dispose();
            }

            MemoryProcesses.Clear();
            var content = WorkflowDataObject.GetContent();

            foreach (var c in content)
            {
                if (c.Value is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

            if (WorkflowDataObject is IDisposable d)
            {
                d.Dispose();
            }
        }