so in simple program, have 1 progress bar , 1 button.
now button read 2 tables database (mysql example).
just 2 simple select statements reading 2 different tables.
my question is
how can implement progress bar such after reads/selects first table, progress bar value reset 0 , continue on reading next table , increment again progress bar?
this functionality similar when installing applications, every file copy has separate progress using 1 progress bar.
if provide examples helpful.
much better if provide backgroundworker well
you have idea: if have questions, please let me know.
async private void button_click_1(object sender, routedeventargs e) { await task.factory.startnew(executesql1); updateprogressbar(0); await task.factory.startnew(executesql2); updateprogressbar(0); } private void executesql1() { (int = 0; < 100; i++) { int progressbarvalue = i; task.factory.startnew(() => updateprogressbar(progressbarvalue), cancellationtoken.none, taskcreationoptions.none, uischeduler); thread.sleep(50); } } private void executesql2() { (int = 0; < 100; i++) { int progressbarvalue = i; task.factory.startnew(() => updateprogressbar(progressbarvalue), cancellationtoken.none, taskcreationoptions.none, uischeduler); thread.sleep(100); } } taskscheduler uischeduler; public mainwindow() { initializecomponent(); uischeduler = taskscheduler.fromcurrentsynchronizationcontext(); }
Comments
Post a Comment