textbox update
-
Inside a textbox i add many lines of data, ended with a newline(\r\n) for each of it. For example: Aaa Bbb Ccc Each line must be read in a backgroundWorker1_DoWork event. Basically, is a time delay of a couple of seconds between jumping to the other line to be read and processed. My problem is this: - If i add a new line, WHILE the DoWork is running, the textbox.List.lenght is bigger by 1. What should LOAD that updated List, and pass the next line consecutively, to the worker? At this point i am blank. What i did so far... I inverted the list why? because my processing is not disturbed by each new line added on top, but is accumulating lines at the end, maintaining the lines numbers and contents when it jumps to the next line.
list1.Clear(); label1.Text = ""; list1.AddRange(textBox1.Lines); list1.Reverse(); for (int i = 0; i < list1.Count; i++) { label1.Text += list1\[i\] + nl; }
And now the output is: Ccc Bbb-updateLine Aaa a1-nl a2-nl One solution to updating lines by mistake, and avoid re-processing them, is to completely erase the completed "worked" lines from the List and update somewhere else the finished lines.
-
Inside a textbox i add many lines of data, ended with a newline(\r\n) for each of it. For example: Aaa Bbb Ccc Each line must be read in a backgroundWorker1_DoWork event. Basically, is a time delay of a couple of seconds between jumping to the other line to be read and processed. My problem is this: - If i add a new line, WHILE the DoWork is running, the textbox.List.lenght is bigger by 1. What should LOAD that updated List, and pass the next line consecutively, to the worker? At this point i am blank. What i did so far... I inverted the list why? because my processing is not disturbed by each new line added on top, but is accumulating lines at the end, maintaining the lines numbers and contents when it jumps to the next line.
list1.Clear(); label1.Text = ""; list1.AddRange(textBox1.Lines); list1.Reverse(); for (int i = 0; i < list1.Count; i++) { label1.Text += list1\[i\] + nl; }
And now the output is: Ccc Bbb-updateLine Aaa a1-nl a2-nl One solution to updating lines by mistake, and avoid re-processing them, is to completely erase the completed "worked" lines from the List and update somewhere else the finished lines.
-
Inside a textbox i add many lines of data, ended with a newline(\r\n) for each of it. For example: Aaa Bbb Ccc Each line must be read in a backgroundWorker1_DoWork event. Basically, is a time delay of a couple of seconds between jumping to the other line to be read and processed. My problem is this: - If i add a new line, WHILE the DoWork is running, the textbox.List.lenght is bigger by 1. What should LOAD that updated List, and pass the next line consecutively, to the worker? At this point i am blank. What i did so far... I inverted the list why? because my processing is not disturbed by each new line added on top, but is accumulating lines at the end, maintaining the lines numbers and contents when it jumps to the next line.
list1.Clear(); label1.Text = ""; list1.AddRange(textBox1.Lines); list1.Reverse(); for (int i = 0; i < list1.Count; i++) { label1.Text += list1\[i\] + nl; }
And now the output is: Ccc Bbb-updateLine Aaa a1-nl a2-nl One solution to updating lines by mistake, and avoid re-processing them, is to completely erase the completed "worked" lines from the List and update somewhere else the finished lines.
-
Inside a textbox i add many lines of data, ended with a newline(\r\n) for each of it. For example: Aaa Bbb Ccc Each line must be read in a backgroundWorker1_DoWork event. Basically, is a time delay of a couple of seconds between jumping to the other line to be read and processed. My problem is this: - If i add a new line, WHILE the DoWork is running, the textbox.List.lenght is bigger by 1. What should LOAD that updated List, and pass the next line consecutively, to the worker? At this point i am blank. What i did so far... I inverted the list why? because my processing is not disturbed by each new line added on top, but is accumulating lines at the end, maintaining the lines numbers and contents when it jumps to the next line.
list1.Clear(); label1.Text = ""; list1.AddRange(textBox1.Lines); list1.Reverse(); for (int i = 0; i < list1.Count; i++) { label1.Text += list1\[i\] + nl; }
And now the output is: Ccc Bbb-updateLine Aaa a1-nl a2-nl One solution to updating lines by mistake, and avoid re-processing them, is to completely erase the completed "worked" lines from the List and update somewhere else the finished lines.
Given the different actions the user can perform on the content of the TextBox ... paste, delete selected lines, etc. ... I think your strategy should be to perform whatever content enumeration only when the textBox is not in use. What is the reason you think you need to use a BackGroundWorker here ? If you must use it, look at the use of 'ManualResetEvent, and use of 'Monitor and 'Lock.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali