I have a windows forms app that works well on my development machine. However, I see strange behavior trying to run multiple tasks in parallel after publishing the application. There is no error, but it doesn't work as expected. Here is the code:
private async void Button1_Click(object sender, EventArgs e)
{
    button1.Enabled = false;
    try
    {
        var watch = Stopwatch.StartNew();
        textBox1.Text = $"Processing...";
        await SyncAppDbAsync();
        watch.Stop();
        var time = watch.ElapsedMilliseconds;
        textBox1.Text = $"End successfully. Minutes: {String.Format("{0:0.00}", (double)(time / 1000) / 60)}";
    }
    catch (Exception ex)
    {
        textBox1.Text = $"Message: {ex.Message}, Source: {ex.Source}, HResult: {ex.InnerException}";
    }
}
public async Task SyncAppDbAsync()
{
    //delete tables rows
    // I block the UI for some seconds because not want to write
    // a record if is not deleted
    Task.WaitAll(
        AgenteApp.RemoveAllAgentiAppAsync(),
        RubricaApp.RemoveAllRubricheAppAsync(),
       ...
    );
    //read data da from database
    var readAgents = Task.Run(Agent.GetAgentAsync);
    var readAddressBooks = Task.Run(AddressBook.GetAddressBookAsync);
    ...
    await Task.WhenAll(
         readAgents,
         readAddressBooks,
         ...
     );
    //save data on sqlite database(myDb.db)
    var addAgenti = Task.Run(async () =>
    {
        var progrIndicator = new Progress<int>(AgentiProgress);
        var agenti = AgenteApp.FillAgentiAppFromCompanyAsync(await readAgents, progrIndicator);
        await AgenteApp.AddAgentiAppAsync(await agenti);
    });
    var addRubriche = Task.Run(async () =>
    {
        var progrIndicator = new Progress<int>(RubricheProgress);
        var rubriche = RubricaApp.FillRubricheAppFromCompanyAsync(await readAddressBooks, progrIndicator);
        await RubricaApp.AddRubricheAppAsync(await rubriche);
    });
    await Task.WhenAll(
      addAgenti,
      addRubriche,
     ...
    );
}
Each task in that code corresponds to a table in an sqlite database. The code reads data from one sqlite database and writes to another sqlite database.
I expect this code to take a few minutes to run. In the meantime, there is a progress bar for each table that should update. Instead, the code runs in just a few seconds, the progress bars never update, and the database tables are unchanged. I see this text in my textbox at the end: End successfully. Minutes: 0,02.
What can I do to understand the problem and fix it? Again, this works correctly on my development machine.
UPDATE: Sorry to everyone: code works perfectly fine! I make stupid mistake with a path of sqlite database. I hardcoded in app.config:
I accept suggests on how make dynamic that path So again sorry
 
    