vkvova5
20.08.2011, 23:47
Я делаю вот такой код для бекграунд вокера а он не выполняет то что написано что должно выполнится после завершения дуворк... что делать?
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)
{
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();
}
}
}