Click here to Skip to main content
15,917,005 members

Comments by Bogomil Todorov 2024 (Top 8 by date)

Bogomil Todorov 2024 18-Jan-24 2:30am View    
Thank you very much!
Bogomil Todorov 2024 18-Jan-24 1:43am View    
Thank you very much, especially for the article "Switching From a BackgroundWorker To a Task - It's a Neater Solution, Particularly When Reporting Progress"!
Bogomil Todorov 2024 18-Jan-24 1:40am View    
"A picture is worth a thousand words!"
With the given example it is now clearer to me how to use the tasks and progressBars.
Thank you very much!
Bogomil Todorov 2024 17-Jan-24 8:39am View    
Yes, I can create int variable and increment it :-)

The problem is that this variable is not connected to progressBar. I'm sorry if I'm wasting your time. I still can't handle the issue.
Bogomil Todorov 2024 17-Jan-24 8:31am View    
var progressHandler = new Progress<int>(value =>
{
progressBar1.Value = progressBar1.Value + value;
});
var progress = progressHandler as IProgress<int>;

Task<datatable?>[] tasks = new Task<datatable?>[files.Count];
for (int currentTask = 0; currentTask < files.Count; currentTask++)
{
string file = files[currentTask];
tasks[currentTask] = Task.Run(() =>
{
DataTable? tbl = CSVtoDataTable(file);
progress.Report(1);
return tbl;
});
}
Task.WaitAll(tasks);