zoukankan      html  css  js  c++  java
  • 奇怪的异步调用,那位高手能帮忙看一下?

    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); // 此处报错:"参数计数不匹配。" 请问怎样解决?
              } 

  • 相关阅读:
    Codeforces Round #380(div 2)
    Codeforces Round #378(div 2)
    Codeforces Round #379(div 2)
    CCPC2016合肥现场赛
    CCPC2016沈阳站
    HDU2222 Keywords Search__AC自动机
    poj2185Milking Grid
    POJ2961_kmp
    POJ 2406
    poj 2752Seek the Name, Seek the Fame
  • 原文地址:https://www.cnblogs.com/tianya/p/945893.html
Copyright © 2011-2022 走看看