Thread and ShowDialog

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a problem about threading when using ShowDialog method.

I have 2 forms and first one opens second one as modal. Form2 (second form)
has a progress bar. Any suggesstion.

Thanks.

HEre is my code...

private void Form1_Load(object sender, System.EventArgs e)
{
Thread t = new Thread(new ThreadStart(test));
t.Start();
this.label1.Text = "12 3214 ";
}

private void test()
{
Form2 d = new Form2();
d.TopMost = true;
d.ShowDialog();
}

// Form2 code....

private void Form2_Load(object sender, System.EventArgs e)
{
for(int i = 0 ; i < 100 ; i++)
{
this.progressBar1.Value = i;
Thread.Sleep(50);
}
}


Thanks
 
Fatih said:
I have a problem about threading when using ShowDialog method.

I have 2 forms and first one opens second one as modal. Form2 (second
form)
has a progress bar. Any suggesstion.

Always show your forms in your app's main thread...

A .NET Progress Dialog
<URL:http://www.codeproject.com/cs/miscctrl/progressdialog.asp>

Multithreading + Windows Forms:

<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp>

<URL:http://www.devx.com/dotnet/Article/11358/>

<URL:http://msdn.microsoft.com/library/e...SystemWindowsFormsControlClassInvokeTopic.asp>

Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisualbasic.asp>

Sample:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>
 
Thanks sir but is there any way to open the progress window as modal. (with
ShowDialog method)
 
Considering how ubiquitous the need for progress dialogs is -- and how
complex it is to program them -- why hasn't any of the component vendors
added it to their suites? I would *totally* pay money for one!

handa29
 
Back
Top