Good day everyone.
There is a class that performs some work:
public class MyNew
{
private bool Initialize()
{
this.InitializeProgressDialog();
return true;
}
private void InitializeProgressDialog()
{
this.ProgressDialog = new ProgressBar();
this.ProgressDialog.setProgressBarLimit(this.Count);
this.ProgressDialog.Show();
}
private void CreateBMP()
{
this.ProgressDialog.updateStatus("Creating something", true);
}
private void CreateSmall()
{
this.ProgressDialog.updateStatus("Creating something new", false);
}
private void CreateBigger()
{
int[] array;
array = new int[]
{
1,
2,
3,
4,
5
};
string[] array2 = new string[array.Length];
for (int i = 0; i < array.Length; i++)
{
this.ProgressDialog.updateStatus(string.Concat(new object[]
{
"Creating something else: ",
i + 1,
" of ",
array.Length
}), true);
That is, in ProgressDialog (created visually distribute the component on the form) by passing the label and the parameters of the progressbar.
public partial class ProgressBar : Form
{
MyNew Breack;
public void setProgressBarLimit(int SomeCount)
{
this.progressBarStatus.Maximum = SomeCount + 2;
}
public void updateStatus(string statusText, bool updateBar)
{
if (updateBar)
{
if (this.progressBarStatus.Value < this.progressBarStatus.Maximum)
{
this.progressBarStatus.Value++;
}
this.progressBarStatus.Update();
}
if (statusText != "")
{
this.labelSatus.Text = statusText;
}
this.labelSatus.Update();
}
public ProgressBar()
{
InitializeComponent();
}
How can I unfreeze a form ProgressDialog?
The fact that my class, I also call from another class. That is, this scheme
Class 1-> MyNew-> Progressbar
If I call the class MyNew a new thread, then the form ProgressDialog is not be displayed.
How to stuff a progressbar directly backgroundWorker also do not understand, because to update the form I use is not something running in the DoWork function with parameters and updateStatus and there is already decides how to update the progress bar on the form.
May not go that way?