public void Run()
        {
            waiting = true;

            while (waiting)
            {
                waiting = false;
                EventPublisher.Publish<ActivityExecutingEvent>(new ActivityExecutingEvent()
                {
                    UUID = string.Format("{0}-{1}-{2}-ActivityExecutingEvent", Context.ProcessDefine.ID, Context.ProcessDefine.Version, Context.Activity.ID),
                    Context = Context
                });

                foreach (var workItem in GetExecutingWorkItems(Context.ActivityInst))
                {
                    var workItemContext = new WorkItemContext()
                        {
                            ProcessDefine = Context.ProcessDefine,
                            ProcessInst = Context.ProcessInst,
                            ActivityInst = Context.ActivityInst,
                            WorkItem = workItem,
                            Parameters = Context.Parameters
                        };

                    WorkItemRuntime workItemRuntime = new WorkItemRuntime(engineService, workItemContext);

                    workItemRuntime.Run(workItem);
                }

                EventPublisher.Publish<ActivityExecutedEvent>(new ActivityExecutedEvent()
                {
                    UUID = string.Format("{0}-{1}-{2}-ActivityExecutedEvent", Context.ProcessDefine.ID, Context.ProcessDefine.Version, Context.Activity.ID),
                    Context = Context
                });
            }
        }
 public WorkItemRuntime(IEngineService services, WorkItemContext context)
 {
     this.engineService = services;
     Context = context;
 }