title: C# Access form-object from thread(other class)? Multithreaded object array needed?
body: <blockquote>
    <p><strong>[OT-Intro]</strong></p>
    
    <p><em>I am actually C coder and just started today with C# for the only reason that there is a library existing for that really simplifies my
    life. I am sorry that my knowledge is really weak and I have to admit that I am more interested in finishing this tool than interested in learning a new programming language. I hope you will still help me to solve the issue plus explain me my second question. Thanks!</em></p>
    
    <p><strong>[/OT-Intro]</strong></p>
  </blockquote>
  
  <p>However, I need to access/update a <strong>form object => RichTextBox(.AppendText)</strong> from a <strong>thread (safely) in my multithreaded application</strong>.</p>
  
  <p>More specific, I want programmatically do the follow:</p>
  
  <pre><code>component.OnEvent += delegate(object o) 
  { 
      lock (lockObj) 
      { 
          FormMain.RichTextBox.AppendText("SomeRandomText")
      }; 
  };
  </code></pre>
  
  <p>In case I understand everything right, lock(lockObj) would block the access to RichTextBox, <strong>so this should be saflely updated</strong>?</p>
  
  <p>However, I don't know how to access the RichTextBox (<em>appreciate the easiest if not too slow</em>) way.</p>
  
  <p><strong>And the second question - Multithreaded object array needed?</strong></p>
  
  <p>At the moment I just create one single object like that:</p>
  
  <pre><code>ThreadClass threadclassobj = new ThreadClass (); 
  </code></pre>
  
  <p>And call it for example this way (ofc not this way):</p>
  
  <pre><code>for (;;)
  {
      threadclassobj.StartTheThread(username, password);     
  }
  </code></pre>
  
  <p>StartTheThread looks like this:</p>
  
  <pre><code>public Thread StartTheThread(string param1, string param2)
  {
      var t = new Thread(() =&gt; Check(param1, param2));
      t.Start();
      return t;
  }
  </code></pre>
  
  <p>I used the Lamda-expression method to pass the arguments..</p>
  
  <p>I am just curious how this gets handled, I wonder how one object creates multiple Threads at the same time and work the parameters in the right way.</p>
  
  <p>Normally(in C) i would create an array of ThreadClass.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Regards.</p>