• 奇怪的异步调用,那位高手能帮忙看一下?


    delegate void SetStr(string s);
     private void SetText(string name)
            {
               txtResult.Text = name;
            }
      private void btnFind_Click(object sender, EventArgs e)
            {
                Thread th = new Thread(new ThreadStart(FindFile));
                th.Start();
             }

     private void FindFile()
            {
                string[] m = Directory.GetDirectories(@"c:\\", txtFile.Text.Trim(), SearchOption.AllDirectories);
      string s = "test";
                Invoke(new SetStr(SetText), s);
              } 
    以上可以运行在vs 2005 下;
    但是下面的报错:
    delegate void SetStr(string[] s);
     private void SetText(string[] name)
            {
               for (int i = 0; i < name.Length; i++)
                {
                    txtResult.Text = txtResult.Text + name[i] + "\n";
                }
            }
      private void btnFind_Click(object sender, EventArgs e)
            {
                Thread th = new Thread(new ThreadStart(FindFile));
                th.Start();
             }

     private void FindFile()
            {
                string[] m = Directory.GetDirectories(@"c:\\", txtFile.Text.Trim(), SearchOption.AllDirectories);
      string s = "test";
                Invoke(new SetStr(SetText), m); // 此处报错:"参数计数不匹配。" 请问怎样解决?
              } 

  • 相关阅读:
    ServletContext
    PS切图
    session实战案例
    Array Destruction
    Session详解
    No More Inversions 全网最详细 回文序列的逆序对
    Sum of Paths (DP、预处理)
    cookie详解
    web的状态管理
    简单最大流/最小割复习
  • 原文地址:https://www.cnblogs.com/tianya/p/945893.html
Copyright © 2020-2023  润新知