public void Run()
        {
            waiting = true;
            while (waiting)
            {
                waiting = false;
                var runningActInsts = Persistence.Repository.Query<ActivityInst>().Where(ai => ai.ProcessInstID == Context.ProcessInst.ID && ai.CurrentState == (short)ActivityInstStatus.Running && ai.RollbackFlag == 0).ToArray();
                foreach (ActivityInst activityInst in runningActInsts)
                {
                    ActivityContext activityContext = new ActivityContext()
                    {
                        ProcessInst = Context.ProcessInst,
                        ActivityInst = activityInst,
                        Parameters = Context.Parameters,
                        ProcessDefine = Context.ProcessDefine
                    };
                    ActivityRuntime runtime = new ActivityRuntime(engineService, activityContext);

                    runtime.Run();

                    UpdateActivityInstAndRoute(activityInst);
                }
            }

            CheckAndUpdateProcessInstStatus();
        }
 public ActivityRuntime(IEngineService services, ActivityContext context)
 {
     engineService = services;
     workItems = Persistence.GetWorkItems(context.ActivityInst.ID);
     Context = context;
 }