Hi
in my windows form i sync table from database1 with database2
So i read data from the first and fill the second
The tasks run concurrently
I do know how notify progress in windows progress bar
tableProcessed/ tableToProcess
How can do that without touch performance of syncronization runtime?
private async void Button1_Click(object sender, EventArgs e)
{
try
{
var watch = Stopwatch.StartNew();
//read data from database1
var readAgents = Task.Run(() => Agent.GetAgentAsync());
var readAddressBooks = Task.Run(() => AddressBook.GetAddressBookAsync());
await Task.WhenAll(
readAgents,
readAddressBooks
);
//save data in database2
var addAgenti = Task.Run(async () =>
AgenteApp.AddAgentiAppAsync(await AgenteApp.FillAgentiAppFromCompanyAsync(readAgents.Result))
);
var addRubriche = Task.Run(async () =>
RubricaApp.AddRubricheAppAsync(await RubricaApp.FillRubricheAppFromCompanyAsync(readAddressBooks.Result))
);
await Task.WhenAll(
addAgenti,
addRubriche
);
watch.Stop();
var time = watch.ElapsedMilliseconds;
textBox1.Text = $"End Tasks. Minutes: {String.Format("{0:0.00}", (double)(time / 1000) / 60)}";
}
catch (Exception ex)
{
MessageBox.Show($"Message: {ex.Message}Source: {ex.Source}HResult: {ex.InnerException}");
}
}