T
Tim_Mac
hi,
i have a backgroundworker class which recursively iterates through a
directory, reading the files and folders, and using ReportProgress to
inform the UI that a new file has been read. the Progress_Changed
method appends the filename to a textbox.
the problem is that the events happen so fast that the textbox never
actually gets time to display properly as it udpates, the text is never
displayed until it's all over. all you can see on screen is the
scrollbar getting smaller and smaller.
i would like the user to be able to see the progress as it happens, as
is the point of doing the thing asynchronously in the first place!
what can i do?
here is my code:
private void thread_DoWork(object sender, DoWorkEventArgs e)
{
foreach(string path in this.Paths) // 'Paths' is a List<string>
{
if(Directory.Exists(path))
RecurseFolder(path);
else if(File.Exists(path))
this.thread.ReportProgress(0, path);
}
}
private void RecurseFolder(string path)
{
// ...
}
private void thread_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
this.txt1.Text += e.UserState.ToString() + "\r\n";
}
thanks
tim
i have a backgroundworker class which recursively iterates through a
directory, reading the files and folders, and using ReportProgress to
inform the UI that a new file has been read. the Progress_Changed
method appends the filename to a textbox.
the problem is that the events happen so fast that the textbox never
actually gets time to display properly as it udpates, the text is never
displayed until it's all over. all you can see on screen is the
scrollbar getting smaller and smaller.
i would like the user to be able to see the progress as it happens, as
is the point of doing the thing asynchronously in the first place!
what can i do?
here is my code:
private void thread_DoWork(object sender, DoWorkEventArgs e)
{
foreach(string path in this.Paths) // 'Paths' is a List<string>
{
if(Directory.Exists(path))
RecurseFolder(path);
else if(File.Exists(path))
this.thread.ReportProgress(0, path);
}
}
private void RecurseFolder(string path)
{
// ...
}
private void thread_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
this.txt1.Text += e.UserState.ToString() + "\r\n";
}
thanks
tim