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 WindowsFormsApplication31 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { backgroundWorker1.RunWorkerAsync(this); while (backgroundWorker1.IsBusy) Application.DoEvents(); } string stextBox1 = null; private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { stextBox1 = "sss"; } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { textBox1.Text = stextBox1; Form2 f2 = new Form2(); f2.Show(); this.Hide(); } } }
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 WindowsFormsApplication31 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if(!backgroundWorker1.IsBusy){ backgroundWorker1.RunWorkerAsync(this);} } string stextBox1 = null; private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { stextBox1 = "sss"; } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { textBox1.Text = stextBox1; Form2 f2 = new Form2(); f2.Show(); this.Hide(); } } }