<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Invoking a global async method in code stage in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60250#M13751</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I developed an async method in my Blue Prism object's initial page (global code):&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt; static async Task&amp;lt;string&amp;gt; GetAuthenticationResponseAsync()
    {
       ...
    }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The method returns a string value.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I've tried this:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;string responseData = await GetAuthenticationResponseAsync();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;however, the compiler is complaining:&lt;/P&gt;
&lt;P&gt;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'.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I also tried:&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;responseData = GetAuthenticationResponseAsync().GetAwaiter().GetResult();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is there a way that I could invoke the async method through the code stage?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;S Rashidi&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Mon, 24 Jul 2023 13:38:00 GMT</pubDate>
    <dc:creator>KingSerok</dc:creator>
    <dc:date>2023-07-24T13:38:00Z</dc:date>
    <item>
      <title>Invoking a global async method in code stage</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60250#M13751</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I developed an async method in my Blue Prism object's initial page (global code):&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt; static async Task&amp;lt;string&amp;gt; GetAuthenticationResponseAsync()
    {
       ...
    }
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The method returns a string value.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I've tried this:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;string responseData = await GetAuthenticationResponseAsync();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;however, the compiler is complaining:&lt;/P&gt;
&lt;P&gt;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'.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I also tried:&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;responseData = GetAuthenticationResponseAsync().GetAwaiter().GetResult();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is there a way that I could invoke the async method through the code stage?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;S Rashidi&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 24 Jul 2023 13:38:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60250#M13751</guid>
      <dc:creator>KingSerok</dc:creator>
      <dc:date>2023-07-24T13:38:00Z</dc:date>
    </item>
    <item>
      <title>RE: Invoking a global async method in code stage</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60251#M13752</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.blueprism.com/communities/community-home/digestviewer/viewthread?GroupId=145&amp;amp;MessageKey=65e30866-3e45-4a56-845d-f77e2d3986ec&amp;amp;CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01?utm_source=blueprism&amp;amp;utm_medium=pweb&amp;amp;utm_campaign=gl-web-2022-q1-12-3-community-related-discussions#bm65e30866-3e45-4a56-845d-f77e2d3986ec"&gt;https://community.blueprism.com/communities/community-home/digestviewer/viewthread?GroupId=145&amp;amp;MessageKey=65e30866-3e45-4a56-845d-f77e2d3986ec&amp;amp;CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01?utm_source=blueprism&amp;amp;utm_medium=pweb&amp;amp;utm_campaign=gl-web-2022-q1-12-3-community-related-discussions#bm65e30866-3e45-4a56-845d-f77e2d3986ec&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Brian Clayton&lt;BR /&gt;Applications Consultant&lt;BR /&gt;The Auto Club Group&lt;BR /&gt;America/Dearborn MI&lt;BR /&gt;313-336-1896&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Jul 2023 02:04:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60251#M13752</guid>
      <dc:creator>bclayton1896</dc:creator>
      <dc:date>2023-07-26T02:04:00Z</dc:date>
    </item>
    <item>
      <title>RE: Invoking a global async method in code stage</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60252#M13753</link>
      <description>&lt;P&gt;For Async function&lt;/P&gt;
&lt;P&gt;Here is the best solution for BP code stage I got implemented.&lt;/P&gt;
&lt;P&gt;var result = Task.Run(async () =&amp;gt; await GetAccessToken()).Result;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Mahaboobsubani Shaik&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Dec 2023 02:04:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Invoking-a-global-async-method-in-code-stage/m-p/60252#M13753</guid>
      <dc:creator>smssubhani</dc:creator>
      <dc:date>2023-12-04T02:04:00Z</dc:date>
    </item>
  </channel>
</rss>

