24-07-23 02:38 PM
Hello,
I developed an async method in my Blue Prism object's initial page (global code):
static async Task<string> GetAuthenticationResponseAsync()
{
...
}
The method returns a string value.
Now, I need to invoke this method in the Blue Prism's code stage. How can I invoke an async method in the Blue Prism code stage?
I've tried this:
string responseData = await GetAuthenticationResponseAsync();
however, the compiler is complaining:
The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
I also tried:
responseData = GetAuthenticationResponseAsync().GetAwaiter().GetResult();
This resolved the compiler error, however, when I run the action (code stage), Blue Prism is permanently stuck on the code stage, and I have no option but to terminate Blue Prism via task manager.
Is there a way that I could invoke the async method through the code stage?
Thanks!
26-07-23 03:04 AM
Does this link to a previous thread help you any? It looks like there is an Output() method at the end of the suggested code.
04-12-23 02:04 AM
For Async function
Here is the best solution for BP code stage I got implemented.
var result = Task.Run(async () => await GetAccessToken()).Result;