This is what i do on dotnet 3.5
using System.ComponentModel;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private delegate void progressDelegate(string progress);
private void Form1_Load(object sender, System.EventArgs e)
{
ProgressBar1.Visible = true;
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i <= 50000; i++)
{
progressDelegate m_UpdateText = null;
m_UpdateText = new progressDelegate(progress1);
this.Invoke(m_UpdateText, i.ToString());
}
}
private void progress1(string progress)
{
this.Text = progress;
ProgressBar1.Minimum = 0;
ProgressBar1.Maximum = 50000;
ProgressBar1.Value = Convert.ToInt32(progress);
}
private void BackgroundWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
Interaction.MsgBox("Done proccessing");
this.Text = "Done";
ProgressBar1.Visible = false;
}
}