Hi,
I have the following classical situation;
1)A long operation needs to be done in my application( that has many windows )
2)A progress dialog must be shown in a separate thread
3)The long operation continues in the program main thread.
The problem is,
from the second thread I call ShowDialog(), but this dialog will not be
Modal!!!
Obviously .net modal dialog will only work if all dialogs in the application
are opened in same thread.
in my scenario I can simply switch between two dialogs( the progress dialog
and the backgroud dialog)
How can I show a dialog that is modal to all other dialogs even if the
application dialogs were opened in different threads?
Regards,
Faris
Cole - 15 Oct 2004 17:11 GMT
> 1)A long operation needs to be done in my application( that has many windows )
Can you use delegates invoked async to do the *work* and then when they
return to main thread show your windows appropriately?
Cole
Herfried K. Wagner [MVP] - 15 Oct 2004 17:27 GMT
"Faris Ahmed" <Faris Ahmed@discussions.microsoft.com> schrieb:
> I have the following classical situation;
> 1)A long operation needs to be done in my application
> ( that has many windows )
> 2)A progress dialog must be shown in a separate thread
> 3)The long operation continues in the program main thread.
Always show your forms in the app's main UI thread and use 'Control.Invoke'
to communicate in the tread -> UI direction:
Multithreading:
<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
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/
Stoitcho Goutsev \(100\) [C# MVP] - 16 Oct 2004 15:49 GMT
Hi Faris,
What you need to do is to do it the other way around. Show the dialog from
the UI thread and do the job from a worker thread. Otherwise AFAIK there is
no such a thing as process-modal dialog.
--
HTH
Stoitcho Goutsev (100) [C# MVP]
> Hi,
> I have the following classical situation;
[quoted text clipped - 19 lines]
> Regards,
> Faris