Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. textbox update

textbox update

Scheduled Pinned Locked Moved C#
helptutorialquestionannouncement
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Q12_
    wrote on last edited by
    #1

    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.

    _ L B 3 Replies Last reply
    0
    • _ _Q12_

      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.

      _ Offline
      _ Offline
      _Q12_
      wrote on last edited by
      #2

      i figure out the solution, but i'm still curious whats your resolve though.

      1 Reply Last reply
      0
      • _ _Q12_

        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.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Set up a separate "concurrent queue" for the background worker to access "new lines".

        It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

        1 Reply Last reply
        0
        • _ _Q12_

          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.

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups