日期:2014-05-17  浏览次数:20965 次

BeginInvoke最后一个参数没有意义?
 
在做例子是发现,BeginInvoke最后一个参数没有任何意义?
传一个NULL,或放个什么进去看不到任何变化。


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ASY
{
    public partial class Form1 : Form
    {
        public delegate string delegateInvoke(string parm);
        public delegate string delegateAppendText(string msg);

        public Form1()
        {
            InitializeComponent();
        }

        public string InvokedMethod(string parm)
        {          
            delegateAppendText da = new delegateAppendText(InvokedMethod);
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(da, parm);
            }
            else
            {
                textBox1.Text = parm;
            }
            return "Asy called," + parm  ;
        }

        private void button1_Click(object sender, EventArgs e)
        {
             delegateInvoke delegateinvoke = new delegateInvoke(InvokedMethod);
             delegateinvoke.BeginInvoke("ok", new AsyncCallback(callComplete), null);
        }

        private void callComplete(IAsyncResult ir)
        {
            delegateInvoke di = (delegateInvoke)ir.AsyncState;           
            di.EndInvoke(ir);         
        }
    }
}