C#.NET 动态参数

public delegate void MyDelegate(Label myControl, string myArg2);

private void Button_Click(object sender, EventArgs e)
{
   object[] myArray = new object[2];

   myArray[0] = new Label();
   myArray[1] = "Enter a Value";
   myTextBox.BeginInvoke(new MyDelegate(DelegateMethod), myArray);
}

public void DelegateMethod(Label myControl, string myCaption)
{
   myControl.Location = new Point(16,16);
   myControl.Size = new Size(80, 25);
   myControl.Text = myCaption;
   this.Controls.Add(myControl);
}

===================================

private delegate int MyMethod();
        private void MethodCompleted(IAsyncResult asyncResult)
        {
            if (asyncResult == null) return;
            textBox1.Text = (asyncResult.AsyncState as MyMethod).EndInvoke(asyncResult).ToString();//RefreshOutputFiles()方法返回的结果;
        }
        private void det_OnFinishedEvent()
        {
            MyMethod my = RefreshOutputFiles;
            IAsyncResult asyncResult = my.BeginInvoke(MethodCompleted, my);

            this.BeginInvoke();
        }



[本日志由 fovly 于 2009-10-15 11:15 AM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
评论: 0 | 引用: 0 | 查看次数: 349