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
Herfried K. Wagner [MVP] - 24 Nov 2004 14:25 GMT
"Fatih" <Fatih@discussions.microsoft.com> schrieb:
>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/en-us/cpref/html/frlrfSystemWindowsFormsContro
lClassInvokeTopic.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>

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/
Fatih - 24 Nov 2004 15:27 GMT
Thanks sir but is there any way to open the progress window as modal. (with
ShowDialog method)
> I have a problem about threading when using ShowDialog method.
>
[quoted text clipped - 31 lines]
>
> Thanks
Anthony H - 09 Dec 2004 02:30 GMT
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
Ed Kaim - 13 Dec 2004 15:03 GMT
You can write a progress dialog in about 3 minutes. Check out ProgressBar:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbco
nprogressbarcontroloverview.asp.
> 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
[quoted text clipped - 4 lines]
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!