internal override void Restore(WorkflowSnapshot snapshot)
 {
     if (snapshot != Context.CurrentSnapshot)
     {
         throw new InvalidOperationException("Can not restore paused engine with different snapshot. Create a new instance instead!");
     }
 }
        internal void ExecutePause()
        {
            // Create snapshot with workplan name
            var snapShot = new WorkflowSnapshot {
                WorkplanName = ExecutedWorkflow.Workplan.Name
            };

            // Pause all places or transitions with tokens
            foreach (var holder in GetAllHolders().Where(IsRelevantHolder))
            {
                holder.Pause();
            }

            // Await all transitions to finish up currently executed code
            while (ExecutedWorkflow.Transitions.Any(transition => transition.Executing))
            {
                // This will force a context switch to give CPU time to the transitions
                Thread.Sleep(1);
            }

            // Extract snapshot from holders
            snapShot.Holders = (from holder in GetAllHolders()
                                let tokens = holder.Tokens.ToArray()
                                             where tokens.Length > 0
                                             select new HolderSnapshot
            {
                HolderId = holder.Id,
                Tokens = tokens,
                HolderState = holder.InternalState
            }).ToArray();

            CurrentSnapshot = snapShot;
        }
 /// <summary>
 /// Restore the workflow state from a snapshot
 /// </summary>
 /// <param name="snapshot"></param>
 public void Restore(WorkflowSnapshot snapshot)
 {
     State.Restore(snapshot);
 }
Exemple #4
0
 /// <summary>
 /// Restore the workflow from a snapshot
 /// </summary>
 internal virtual void Restore(WorkflowSnapshot snapshot)
 {
     InvalidState();
 }