Example #1
0
        private void ExecuteWorkflowMethod()
        {
            Runtime.RaiseWorkflowStarted(this);
            var activityToExecute = ExecutionContext.Scheme.RootActivity;

            ExecutionContext.StartExecution();
            while (true)
            {
                var returnActivity = activityToExecute as ReturnActivity;
                if (returnActivity != null)
                {
                    Runtime.RaiseWorkflowCompleted(this, returnActivity.Result);
                    return;
                }
                try
                {
                    var res = activityToExecute.Execute(ExecutionContext);
                    Runtime.RaiseWorkflowCompleted(this, res);
                }
                catch (ActivityExecutionInterruptException ex)
                {
                    try
                    {
                        activityToExecute = ExecutionContext.GetToggledActivity(ex);
                        continue;
                    }
                    catch (Exception ex2)
                    {
                        Runtime.RaiseWorkflowTerminated(this, "GetToggledActivity throw: " + ex2);
                    }
                }
                catch (Exception ex)
                {
                    Runtime.RaiseWorkflowTerminated(this, ex.ToString());
                }
                return;
            }
        }