Create Async Function in the Extension


I have to create a Async Function in the extension but i´m having some problems and i realy need some help to understand what I am doing wrong.
Before I implement the code in the outsystems extension I was able to implement this async function in other project (Test project only) and saw this code working well, but when I implement at the outsystems extensions it doesn´t work...

The file attachment is the extension i´m developing and all the Async code is in the beginning.

Tks for you time.
Hi Gonçalo,

I assume that you're trying to do a multithreading asynchronous function, am I right?
Because Timers already do async but only for one thread at a time.

This is a good Issue, and I would really like to know how to do it with Outsystems.

Hope you'll find an answer soon.


What's wrong with using BPT or timers for this?
First of all, thank you for your replies.
Yes, your assumption is correct... I´m trying to do a multitheading asynchronous function.

I can´t use the timer because the timer only do one thread at the time... In this situation timer only works if i create more than one to execute the same function, but to be honest i would like to avoid the possibility of having to create 5 or 10 timers.

Regarding the BPT... its not possible to use (please correct me if i'm wrong) because i´m trying to execute some store procedures/functions in a external Database, thats why i´m trying to develop an extension thats allows me to execute some functions/store procedures asynchronously.

Tks for your help.

Gonçalo, you can call actions from an extension inside the action which implements an automatic activity, so you can call the stored procedures from a BPT process.
Adding to my response, steer away from multi-threaded scenarios as much as possible since they may cause situations where you may end up screwing up your Application Pool and causing application downtime.
I *highly* suggest that if you want to do this, do it as a separate .NET Web Service and call that service from your application. As Ricardo points out, multi-threaded code in Web apps is a recipe for disaster. Isolate it (and the logic) as much as possible.

Also, this kind of logic may scale much more quickly than your application itself in terms of resource use. Make it a Web Service, engineer it so that it doesn't need to store any state, and put it behind a load balancer so you can scale it as needed independently of your application.

I agree with Justin, It's best to do multi threading externally windows services and have your Web app communicate with it via Web services. You wouldn't want CPU intensive task handled by your Web app! Simple background task ok but anything that is going to take a long time to process and consume alot of resouces is not something you should do with a web app!
Hello again,
First of all, I want to thank you all for the help...
At this time we are trying to develop the multi threading via web services.
Once again, tks for your help.
Best Regards,
Gonçalo Pereira
Again, why not use BPT ?

Have you tried it? Don't have it licensed?

With BPT you'd keep your solution inside the Outsystems Platform and not have to go through the hassle of maintaining a parallel system.