Hi, I'm making an application where I need to run a call to an Api in the background:
Main{
Metodo();
}
Metodo(){
for(i=0,i<100,i++){Metodo2(i)
}
Método2(int i){
apiThread2 = new Thread(() => LlamadaAUnaApi);
apiThread2.IsBackground = true;
apiThread2.Start();
}
The thing is that the application ends before the Threads run, I have tried to add them to a Threads list but when the Método2
ends they are not active apiThread2
. I know that if at the end of método2
I do apiThread2.Join();
wait for that thread but I would like as long as Metodo()
continue with their things and would like to do the Join
at the end of the Main running the list of Threads.
Is this possible in any way?