• C#异步Tree


     private void Tree_AfterExpand(object sender, TreeViewEventArgs e)
            {
                int FileID = int.Parse(((ListItem)comboxFile.Items[comboxFile.SelectedIndex]).ID);
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += new DoWorkEventHandler(bw_DoWork);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

                object[] oArgs = new object[] { e.Node, FileID };
                bw.RunWorkerAsync(oArgs);
                bomTree.SelectedNode = e.Node;
            }

      private void bw_DoWork(object sender, DoWorkEventArgs e)

            {
                object[] oArgs = e.Argument as object[];
                TreeNode tn = oArgs[0as TreeNode;
                int FileID = int.Parse(oArgs[1].ToString());
                DataAccess da = new DataAccess();
                DataTable dtChildren = null;
                DataTable dgvlist = null;
                if (tn.Tag != null)
                {
                    dtChildren = new DataTable();
                    dtChildren = GetData();
                    dgvlist = new DataTable();
                    dgvlist =GetData(); 
                }
                else
                {
                    dtChildren = new DataTable();
                    dtChildren =da.SearchChildren(FileID, tn.Text + "%");
                }

                e.Result = new object[] { tn, dtChildren, dgvlist };
            }
     private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                object[] oResult = e.Result as object[];
                TreeNode tNodeParent = oResult[0as TreeNode;
                DataTable dtChildren = oResult[1as DataTable;
                DataTable dgvlist = oResult[2as DataTable;
                ArrayList arr = new ArrayList();
                
               
                //dosomething

            } 

  • 相关阅读:
    Web2.0技能评测
    [收藏]流程设计和优化原则
    [读书笔记1] 卓有成效的管理者(彼得.德鲁克)
    [读书笔记3] 卓有成效的管理者聚焦贡献
    [读书笔记2] 卓有成效的管理者管理时间
    动态生成的Web软件 应该如何设计???
    Logs
    JQuery推荐插件(200+)
    Spring AOP 实例
    《JavaScript凌厉开发Ext详解与实践》一书说了些什么
  • 原文地址:https://www.cnblogs.com/keepsilence/p/2465929.html
Copyright © 2020-2023  润新知