// Returns a handle to a previously started program public WorkflowHandle GetProgramHandle(Guid programId) { WorkflowHandle handle; if (!memoryWorkflows.ContainsKey(programId)) { handle = new WorkflowHandle(programId); } else { handle = memoryWorkflows[programId]; } return(handle); }
// Starts a new program public WorkflowHandle RunProgram(Activity program) { var context = new WorkflowInstanceContext(); // Q: should a context be completely independent? // but the queue(s) in the context should be serialized anyway... var handle = new WorkflowHandle(context); memoryWorkflows.Add(handle.ProgramId, handle); // TODO: Separate creation and execution. // Consider introducing an execution queue? context.ExecuteActivity(program); return(handle); }