Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I schedule a child activity to execute *before* the parent is completed?
    text
    copied!<p>I have a WF (4.5) workflow activity that creates a child workflow (evaluating a VisualBasicValue expression). I need the result <strong>before</strong> I complete the parent workflow.</p> <p>I add the expression to the metadata like this:</p> <pre><code>private VisualBasicValue&lt;string&gt; _expression; protected override void CacheMetadata(NativeActivityMetadata metadata) { base.CacheMetadata(metadata); var visualBasicValue = (VisualBasicValue&lt;string&gt;)(_childActivity.Text.Expression); var expressionText = visualBasicValue.ExpressionText; _expression = new VisualBasicValue&lt;string&gt;(expressionText); metadata.AddChild(_expression); } </code></pre> <p>I tried scheduling the activity in the Execute method like this:</p> <pre><code>protected override void Execute(NativeActivityContext context) { context.ScheduleActivity(context, _expression, OnCompleted); Result.Set(context, _value); } </code></pre> <p>With a callback of:</p> <pre><code>private void OnCompleted(NativeActivityContext context, ActivityInstance completedInstance, string result) { _value = result; } </code></pre> <p>Unfortunately, the _expression activity is only executed <strong>after</strong> the parent's execution method returns. Adding it as an implementation child doesn't work (it cannot work as an implementation child, as it is supposed to evaluate an expression that contains variables external to the parent).</p> <p>Any ideas how to overcome this and execute within the execution context?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload