当前位置:编程学习 > C#/ASP.NET >>

后台线程如何调用主线程的函数呢

主窗口 主线程

        //自已写了一个RichTextBox的函数。这样操作就方便多了。后台线程想调用,把后台的信息直接更新到主窗口上。
    
        public void AppNotice(string msg, Color color, int I, bool bold)
        {
            lock (Notice)
            {
                // Notice.SelectionColor = Color.FromArgb(133, 183, 12);这是RGB设置
                this.NoticerichTextBox.AppendText(msg);
                int StartI = (Notice.Text.Length - msg.Length);
                int EndI = Notice.Text.Length;
                this.NoticerichTextBox.Select(StartI, EndI);
                this.NoticerichTextBox.SelectionColor = color;
                if (bold)
                {
                    NoticerichTextBox.SelectionFont = new Font("Tahoma", I, FontStyle.Bold);
                }
                else
                {
                    NoticerichTextBox.SelectionFont = new Font("Tahoma", I, FontStyle.Regular);
                }
                this.NoticerichTextBox.Select(EndI, EndI);
            }
        }
          
       private void button13_Click(object sender, EventArgs e)
        {
            if (button13.Text == "导出")
            {
                GetLogs GetLogs = new GetLogs();
                ExportLogs = new Thread(new ThreadStart(GetLogs.GetLogVoid));
                ExportLogs.IsBackground = true;
                ExportLogs.Name = "ExportLogs";
                ExportLogs.Start();
                button13.Text = "取消";
            }
            else
            {
                ExportLogs.Abort();
                button13.Text = "导出";
            }
        }


另下一个文件,另一个一个线程。

如何做呢。。不懂。。。看了好多委托,但还是不会求思络跟代码。
namespace WindowsFormsApplication1
{
    
} --------------------编程问答-------------------- 用 Form.invoke --------------------编程问答-------------------- 不明喔。。可以说下思络吗?谢谢哈。。 --------------------编程问答-------------------- http://blog.csdn.net/sandy945/article/details/6948702
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,