WorkflowApplication.Run Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Elindítja vagy folytatja egy munkafolyamat-példány végrehajtását.
Túlterhelések
| Name | Description |
|---|---|
| Run() |
Elindítja vagy folytatja egy munkafolyamat-példány végrehajtását. |
| Run(TimeSpan) |
Elindítja vagy folytatja egy munkafolyamat-példány végrehajtását a megadott időtúllépési időköz használatával. |
Megjegyzések
Hívja meg ezt a metódust egy újonnan létrehozott munkafolyamat-példány végrehajtásának elindításához.
Run()
Elindítja vagy folytatja egy munkafolyamat-példány végrehajtását.
public:
void Run();
public void Run();
member this.Run : unit -> unit
Public Sub Run ()
Példák
Az alábbi példa egy munkafolyamatot üzemeltet a következővel WorkflowApplication: . A WorkflowApplication rendszer a megadott munkafolyamat-definícióval hoz létre egy példányt, kezeli a kívánt munkafolyamat-életciklus-eseményeket, és meghívja a munkafolyamatot egy hívással.Run A munkafolyamat befejezésekor a következő kimenet jelenik meg a konzolon.
Starting the workflow.
Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Idle.
Ending the workflow.
Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Completed
Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Unloaded.
Activity wf = new Sequence
{
Activities =
{
new WriteLine
{
Text = "Starting the workflow."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new WriteLine
{
Text = "Ending the workflow."
}
}
};
// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);
// Subscribe to any desired workflow lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
if (e.CompletionState == ActivityInstanceState.Faulted)
{
Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.TerminationException.GetType().FullName,
e.TerminationException.Message);
}
else if (e.CompletionState == ActivityInstanceState.Canceled)
{
Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
}
else
{
Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
// Outputs can be retrieved from the Outputs dictionary,
// keyed by argument name.
// Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
}
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
// Display the exception that caused the workflow
// to abort.
Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.Reason.GetType().FullName,
e.Reason.Message);
};
wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
// Perform any processing that should occur
// when a workflow goes idle. If the workflow can persist,
// both Idle and PersistableIdle are called in that order.
Console.WriteLine("Workflow {0} Idle.", e.InstanceId);
};
wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
// Instruct the runtime to persist and unload the workflow
return PersistableIdleAction.Unload;
};
wfApp.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId);
};
wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
// Display the unhandled exception.
Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
e.InstanceId, e.UnhandledException.Message);
Console.WriteLine("ExceptionSource: {0} - {1}",
e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);
// Instruct the runtime to terminate the workflow.
// Other choices are Abort and Cancel
return UnhandledExceptionAction.Terminate;
};
// Run the workflow.
wfApp.Run();
Megjegyzések
Hívja meg ezt a metódust egy újonnan létrehozott munkafolyamat-példány végrehajtásának elindításához.
Ha a futtatási művelet nem fejeződik be 30 másodpercen belül, a rendszer egy TimeoutException műveletet indít el.
A következőre érvényes:
Run(TimeSpan)
Elindítja vagy folytatja egy munkafolyamat-példány végrehajtását a megadott időtúllépési időköz használatával.
public:
void Run(TimeSpan timeout);
public void Run(TimeSpan timeout);
member this.Run : TimeSpan -> unit
Public Sub Run (timeout As TimeSpan)
Paraméterek
- timeout
- TimeSpan
Hívja meg ezt a metódust egy újonnan létrehozott munkafolyamat-példány végrehajtásának elindításához.
Az az intervallum, amelyben a futtatási műveletnek befejeződnie kell a művelet megszakítása és TimeoutException a művelet eldobása előtt.
Példák
Az alábbi példa egy munkafolyamatot üzemeltet a következővel WorkflowApplication: . A WorkflowApplication rendszer a megadott munkafolyamat-definícióval hoz létre egy példányt, kezeli a kívánt munkafolyamat-életciklus-eseményeket, és meghívja a munkafolyamatot egy hívással.Run A munkafolyamat befejezésekor a következő kimenet jelenik meg a konzolon.
Starting the workflow.
Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Idle.
Ending the workflow.
Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Completed
Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Unloaded.
Activity wf = new Sequence
{
Activities =
{
new WriteLine
{
Text = "Starting the workflow."
},
new Delay
{
Duration = TimeSpan.FromSeconds(5)
},
new WriteLine
{
Text = "Ending the workflow."
}
}
};
// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);
// Subscribe to any desired workflow lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
if (e.CompletionState == ActivityInstanceState.Faulted)
{
Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.TerminationException.GetType().FullName,
e.TerminationException.Message);
}
else if (e.CompletionState == ActivityInstanceState.Canceled)
{
Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
}
else
{
Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
// Outputs can be retrieved from the Outputs dictionary,
// keyed by argument name.
// Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
}
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
// Display the exception that caused the workflow
// to abort.
Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.Reason.GetType().FullName,
e.Reason.Message);
};
wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
// Perform any processing that should occur
// when a workflow goes idle. If the workflow can persist,
// both Idle and PersistableIdle are called in that order.
Console.WriteLine("Workflow {0} Idle.", e.InstanceId);
};
wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
// Instruct the runtime to persist and unload the workflow
return PersistableIdleAction.Unload;
};
wfApp.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId);
};
wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
// Display the unhandled exception.
Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
e.InstanceId, e.UnhandledException.Message);
Console.WriteLine("ExceptionSource: {0} - {1}",
e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);
// Instruct the runtime to terminate the workflow.
// Other choices are Abort and Cancel
return UnhandledExceptionAction.Terminate;
};
// Run the workflow.
wfApp.Run();
Megjegyzések
Vegye figyelembe, hogy ezzel ellentétben Invokeez a módszer csak akkor időtúllépést ér el, ha a munkafolyamat nem a megadott idő alatt indul el, ahelyett, hogy a megadott idő alatt kellene befejeződnie. Ennek az az oka, hogy Invoke a munkafolyamatot szinkron módon hajtja végre (blokkolja a gazdagépszálat), miközben Run aszinkron módon hajtja végre, csak addig blokkolja a gazdagépszálat, amíg a munkafolyamat elindul.