0
I have a button
normal that performs three tasks, I want that when the tasks are running stay on the same line until the work is finished, without locking the program.
I know there is a method of its own Task
ContinueWith()
and Wait()
, but I’m new to the asynchrony part.
private void Btn_Click(object sender, EventArgs e)
{
Tarefas(); // permancer nessa linha enquanto não terminar
MessageBox.Show("Terminado!");
}
private void Tarefas()
{
Task.Run(() =>
{
//...
});
Task.Run(() =>
{
//...
});
Task.Run(() =>
{
//...
});
}
How do I work with multiple tasks managing all within a method and finally take this method and know if all within it are finished?
Just out of curiosity: why do you need these Task’s?
– Jéf Bueno
I am developing a random color ARGB using Color.Fromargb(), each color will have a Number. Ex: Color.Fromargb(1,2,3)
– sYsTeM
And you need to use Task’s for that? Why don’t you synchronise?
– Jéf Bueno
Not to crash the program, I learned just by doing this way using tasks rsrs
– sYsTeM
You say don’t lock the UI?
– Jéf Bueno
That, my WF app
– sYsTeM