Exit Workflow Execution from Invoke Code

Today I tried a tiny C# snippet to exit the workflow execution.

Console.WriteLine("Terminating");
Environment.Exit(0);

The executor is launched, also the C# compiler and it is also ended …

image

… but the workflow is not terminated.

image

It remains in the execution state.

Two questions:

  1. Should Environment.Exit be avoided in an Invoke Code activity?
  2. What is the correct procedure to completely exit a workflow using Invoke Code activity?

Thanks for hints and tips.

Hi Stefan,

You can set boolean variable an if condition. So you can check then and if boolean is true, then go to end.
Let this boolean variable = argument output → So you can check after the workflow if the invoke is done to end or aborted.

Best regards
Mahmoud

1 Like

@Dawodm

Hello Mahmoud,
thank you very much for your reply.
As far as I can say stops the command Environment.Exit the execution of the bot, but the Executor runs further. From an operational perspective, I would provide a governance rule here that prohibits the use of this method. What do you mean?
Best regards
Stefan

Good idea

1 Like