question:
Can i perform a flush like function to a richtextbox?
reason:
I am writing ~20-40 lines of text at a time to a richtextbox using a loop, my issue is that the whole GUI freezes during that time and nothing can be seen until everything has been written to the richtextbox and the code moves on. I want to write each line to the screen immediately if possible to avoid freezing. I know in console i can use a aFileStream.Flush() command to perform this function. Is there a similar function for aFileStream.appendtext()? My googleFu is weak today and i cant find any examples of this online. Any help is appreciated.
sample code:
foreach (string fullPath in appDataDirectories)
{
//update progess bar
progresbarupdate();
//split file path in to parts
string[] folders = fullPath.Split('\\');
//print out create time for directory
DateTime creationTimeUtc = Directory.GetCreationTimeUtc(fullPath);
String ctime = creationTimeUtc.ToString();
//create String
String printable = String.Format("{0,-50}\t{1}", ctime, fullPath);
output.AppendText(printable + "\n");
}
I don’t think so you will be able to achieve the unfreezing of the RichTextBox by a flush
You can use the BackgroundWorker to do some work in the background on a separate thread and then invoke the Text action of the RichTextBox
Please see my example that shows the RichTextBox does not freeze