public void Start() { WorkflowSchedulerService sheduler; // init all activities ActivityExecutionContextManager manager = new ActivityExecutionContextManager(this); ActivityExecutionContext context = manager.CreateExecutionContext(GetWorkflowDefinition()); GetWorkflowDefinition().InitializeInternal(context); sheduler = (WorkflowSchedulerService)runtime.GetService(typeof(WorkflowSchedulerService)); //sheduler.Schedule (new WaitCallback (WorkflowProcessor.RunWorkflow), guid); WorkflowProcessor.RunWorkflow(guid); }
public void Unload() { using (new WorkflowTraceTransfer(this.InstanceId)) { if (_runtime == null || _runtime.GetService <WorkflowPersistenceService>() == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, ExecutionStringManager.MissingPersistenceService, this.InstanceId)); } while (true) { WorkflowExecutor executor = _runtime.Load(this); if (executor.IsInstanceValid) { try { executor.Unload(); return; } catch (InvalidOperationException) { if (executor.IsInstanceValid) { throw; } } catch (ExecutorLocksHeldException e) { try { e.Handle.WaitOne(/* maybe should have a timeout here?*/); } catch (ObjectDisposedException) { // If an ObjectDisposedException is thrown because // the WaitHandle has already closed, nothing to worry // about. Move on. } } } } } }