You can develop your custom control inherited from ProgressBar.
Put a backgroundworker in the code and increase the value of progressbar in Dowork method og Backgroundworker.
Here is a sample.
public class MyProgressBar : ProgressBar
{
System.ComponentModel.BackgroundWorker bgv = new System.ComponentModel.BackgroundWorker();
public MyProgressBar()
{
Control.CheckForIllegalCrossThreadCalls = false;
bgv.DoWork += new System.ComponentModel.DoWorkEventHandler(bgv_DoWork);
}
void bgv_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
while (true)
{
if (this.Value + IncrementValue > this.Maximum)
{
if (this.Value + IncrementValue - this.Maximum < this.Minimum)
{
this.Value = this.Minimum;
}
else
{
this.Value = this.Value + IncrementValue - this.Maximum;
}
}
this.Value += IncrementValue;
System.Threading.Thread.Sleep(IntervalBetveenIncrement);
}
}
private int _IntervalBetveenIncrement = 500;
public int IntervalBetveenIncrement
{
get { return _IntervalBetveenIncrement; }
set { _IntervalBetveenIncrement = value; }
}
private int _IncrementValue = 25;
public int IncrementValue
{
get { return _IncrementValue; }
set { _IncrementValue = value; }
}
public void Start()
{
bgv.RunWorkerAsync();
}
public void Stop()
{
bgv.CancelAsync();
}
public bool IsWorking
{
get { return bgv.IsBusy; }
}
}
To run the control call it's start method. And to stop call stop method.
Note: This is a not well tested code. If you plan to use this code you should handle these situations before using in your project.Ex:Calling start twice may crash.