Jump to content

Problem handling delegates

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
rbk_achilles

rbk_achilles

    Newbie

  • Members
  • Pip
  • 1 posts
// [B]DirMgr.cs[/B]

void Scan()
        {
            
            while (scanFlag == true)
            {
                List<string> recentList = new List<string>();
                FetchList(scanDir, recentList);
                contentList = recentList;
                form1.setText(contentList);
                Thread.Sleep(scanDelay);
            }
        }
// [B]Form1.cs[/B]

 public void setText(List<string> contents)
        {

            
            [COLOR="Red"]richTextBox1.AppendText("\n--------------------");[/COLOR]
            foreach (string str in contents)
                richTextBox1.AppendText("\n" + str);
                      
        }
on the red line i get the following runtime-error

{"Cross-thread operation not valid: Control 'richTextBox1' accessed from a thread other than the thread it was created on."}

Please help ASAP

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
This forum has some so-called code-tags. Use them instead of using character made lines. I've added the code-tags this time, but you shall remember them yourself next time.