What I am trying to achieve is to add text after every operation to a RichTextBox. The problem is that these operations take some time and instead of viewing the appended text after every operation finishes, I view them all at the end of the routine.
Semi-Pseudo code:
RichTextBox richTextBox = new RichTextBox()
if (Operation1())
{
richTextBox.AppendText("Operation1 finished");
if (Operation2())
{
richTextBox.AppendText("Operation2 finished");
if (Operation3())
{
richTextBox.AppendText("Operation3 finished");
}
}
}
The problem is that I view the appended text of operation 1 & 2 after the operation 3 is finished.
I read somewhere that I need to use something called BackgroundWorker???
Pravesh Singh
17-Dec-2013Hi Jeet,
Using BackgroundWorker, you would just put the background work into DoWork, and the update into RunWorkerCompleted:
You'll notice that this runs afoul of "DRY". You could always consider abstracting the tasks for each step using something like: