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

winform 异步实现等待窗体的lable怎么赋值

  public partial class Form2 : Form
    {
        public event EventHandler OnDoSomething;


        public Form2() {
            this.Load += new System.EventHandler(this.Form2_Load_1); 
        }    

        private void Form2_Load_1(object sender, EventArgs e)
        {
            Label l = new Label();
            l.Text = "dsaads";
            l.BorderStyle = BorderStyle.FixedSingle;
            this.Controls.Add(l);
            this.Show();
            if (OnDoSomething != null)
            {
                OnDoSomething(null, null);
                this.Close();
            } 
        } 
       
    }

------解决方案--------------------
  public partial class Form2 : Form
    {
        public event EventHandler OnDoSomething;


        public Form2() {
            this.Load += new System.EventHandler(this.Form2_Load_1); 
        //}    

        //private void Form2_Load_1(object sender, EventArgs e)
        //{
            Label l = new Label();
            l.Text = "dsaads";
            l.BorderStyle = BorderStyle.FixedSingle;
            this.Controls.Add(l);
            this.Show();
            if (OnDoSomething != null)
            {
                OnDoSomething(null, null);
                this.Close();
         &nbs