Solved this program:accessed from a thread other than the thread it was created on.

来源:互联网 发布:yy刷人气软件 编辑:程序博客网 时间:2024/05/29 18:58


protected void myWatcher_Created(object sender, FileSystemEventArgs e)
{
     string s = "ChangeType :: " + e.ChangeType.ToString() + "/nFullPath ::" + e.FullPath.ToString() + "/n/n";
     AppendText(s);
}                      

private delegate void AppendTextHandler(string s);

private void AppendText(string s)
{
     if( richTextBox1.InvokeRequired )
           richTextBox1.Invoke(new AppendTextHandler(AppendText), new object[]{s});
     else
           richTextBox1.Text += s;
}

原创粉丝点击