# Invoke async c# code

**URL:** <https://forum.uipath.com/t/invoke-async-c-code/264771>\
**Category:** Activities\
**Tags:** studio, error, system, activities\
**Created:** [October 26, 2020, 2:15pm UTC](https://forum.uipath.com/t/invoke-async-c-code/264771 "2020-10-26T14:15:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Foertsch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/foertsch/32/101913_2.png) [@Foertsch](https://forum.uipath.com/u/Foertsch)\
**Post date:** [October 26, 2020, 2:15pm UTC](https://forum.uipath.com/t/invoke-async-c-code/264771/1 "2020-10-26T14:15:30Z")

</div>

Hello, community.

I encountered a problem with C# code execution, namely, when executing an asynchronous method, the execution of the entire project is suspended on Invoke Code and is not executed further.

In the search engine I found a similar problem with the user: [https://stackoverflow.com/questions/52446016/how-to-invoke-async-activity-in-uipath](https://stackoverflow.com/questions/52446016/how-to-invoke-async-activity-in-uipath)

His problem is exactly the same as mine.

No one has ever encountered such a thing?

---

<div class="post-metadata">

**Author:** ![Foertsch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/foertsch/32/101913_2.png) [@Foertsch](https://forum.uipath.com/u/Foertsch)\
**Post date:** [October 26, 2020, 2:20pm UTC](https://forum.uipath.com/t/invoke-async-c-code/264771/2 "2020-10-26T14:20:55Z")

</div>

I use a third-party nuget package from the repository. It is a class library. I use them to access the service’s API. The code contains specific syntax that may not be clear because it uses the service’s API keywords. But I assure you, any call to an asynchronous method via Invoke Code will cause a “stop” in the project.

But maybe I’m wrong, and it’s also about the HTTP request… Since my code contains an HTTP request, and I can’t debug it, or at least call MessageBox at certain stages of code execution…

---

<div class="post-metadata">

**Author:** ![Foertsch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/foertsch/32/101913_2.png) [@Foertsch](https://forum.uipath.com/u/Foertsch)\
**Post date:** [October 28, 2020, 2:27pm UTC](https://forum.uipath.com/t/invoke-async-c-code/264771/3 "2020-10-28T14:27:39Z")

</div>

Find errors. Any interaction of this type with the code causes the process to hang. More precisely, invoke code runs indefinitely and does not terminate.  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/6/c/6c94e04535eda34e6419e26b5f26141578cc9c25.png)

I’m talking about the type: System.Threading.Tasks.Task\<\>

I would like to know what exactly is causing the problem and how to solve it… Since the error forces you to look for workarounds that are much more difficult to implement! But, apparently, it is not my fate to hear any comments from developers on this issue… Anyway, thank you all for your attention.

---

<div class="post-metadata">

**Author:** ![loginerror](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/loginerror/32/22614_2.png) [@loginerror](https://forum.uipath.com/u/loginerror)\
**Post date:** [December 2, 2020, 12:52pm UTC](https://forum.uipath.com/t/invoke-async-c-code/264771/4 "2020-12-02T12:52:53Z")

</div>

Hi @Foertsch

Would this help you here?  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/6/7/67a1404a185bf0f5df18a267f3b0dfd80bbe4497.png)

---

<div class="post-metadata">

**Author:** ![sergio85](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sergio85/32/176630_2.png) [@sergio85](https://forum.uipath.com/u/sergio85)\
**Post date:** [October 27, 2023, 7:06am UTC](https://forum.uipath.com/t/invoke-async-c-code/264771/5 "2023-10-27T07:06:43Z")

</div>

Hi,

I am also facing the same issue with “async System.Threading.Tasks.Task” in invoke code. I have a for each and then an invoke code inside of it. However, when the first iteration is suspended, the second iteration immediately starts and I need synchronously. I used this library because I am implementing a code with ExchangeWebService (EWS) with OAuth2.

Did you find a solution to implement this kind of method?

---

<div class="post-metadata">

**Author:** ![loginerror](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/loginerror/32/22614_2.png) [@loginerror](https://forum.uipath.com/u/loginerror)\
**Post date:** [December 13, 2023, 4:06pm UTC](https://forum.uipath.com/t/invoke-async-c-code/264771/6 "2023-12-13T16:06:16Z")

</div>

I think you can potentially do this with the new Coded Workflows feature (starting from Studio 2023.10).

Please have a look at this sample project that I got while testing things with SOAP requests and which uses an async task:  
[Generating code with Coded Workflows to send SOAP requests](https://forum.uipath.com/t/generating-code-with-coded-workflows-to-send-soap-requests/702479)
