Is it possible to hang up the creation of a task on a button, so that it does not end when the button is exited, or do you have to store the tasks in some list?
Scenario:
I click on the button, a background long task is created that does not interrupt the UI.
If you do this:
private void btnToExcel_Click(object sender, EventArgs e) { btnToExcel.Enabled = false; var excl=new ExcelCreator(tbConvDbPath.Text, tbPathToExcel.Text, AddText); taskList.Add(Task.Run(()=> excl.Create())); btnToExcel.Enabled = true;//После завершения задачи } Then only 1 instruction is executed in the method ...