zoukankan      html  css  js  c++  java
  • 委托、线程的用法

    委托用法简单步骤:

    1,定义一个委托

    public delegate void MyInvoke(TreeNode str); 

    2,定义需投入委托操作的方法

    /// <summary>
            
    /// 1,利用this.Invoke封装添加节点   
            
    /// 2,还原部分显示信息
            
    /// </summary>
            private void CreateTreeNode(TreeNode node)
            {
                
    this.trColorGroup.Nodes.Add(node);
                
    if (trColorGroup.Nodes[0].Nodes.Count > 0)
                    trColorGroup.SelectedNode 
    = trColorGroup.Nodes[0].Nodes[0];
                
    this.Text = this.Text.Replace(Definition.SHOW_WAITING_MESSAGE, "");
                
    this.Enabled = true;
            }

    3,执行委托

    MyInvoke mi = new MyInvoke(CreateTreeNode);
    this.Invoke(mi,firstLevelNode);


    线程用法:

    1,定义一个线程

    Thread thread = null;

    2,定义需用线程加载的方法

    private void LoadColorGList(Object sWhere)
    {
        
    //带参数的方法
    }

    3,执行线程

    thread = new Thread(new ParameterizedThreadStart(LoadColorGList));
    thread.Start(sWhere);

     
    4,终止线程

    if (thread != null)
    {
    thread.Abort();
    }
  • 相关阅读:
    MongoDB分页处理方案(适用于一般数据库的分页方法)
    linux java cpu 100%
    ueditor
    mysql深入,nginx原理
    spring mvc ajax file upload
    shiro session timeout ajax
    spring 源码解析 pdf
    linux下Nginx+tomcat整合的安装与配置
    Mac 环境下搭建Nginx + Tomcat集群
    easymock 搭建
  • 原文地址:https://www.cnblogs.com/xvqm00/p/1651551.html
Copyright © 2011-2022 走看看