473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

threaded modal window

Hi to everybody,

I have the following situation:
I have a lengthy operation inside a desktop application - something that has
to be executed on the main thread of the app (this is a must)
....
server.callLennghtyOperation(...)
....
While this operation is executing, I'd like to show a Form (practically a
modal form, that permits no access to the other forms of the application),
just to inform the user about the fact that the operation is being procesed.

Please can you give some ideeas how to do this.

I was thinkin on starting a thread just before the operation, that outputs a
form (well, still got the problem that it has to behave as a modal
window!!!), and after the operation completes signaling the thread that the
it can stop.
I am v much thinking in plain win api terms, being still new to .net.

Thanks in advance,
Andrea
Mar 7 '06 #1
3 1364
a threaded modal window is a bit of a misnomer, there really is no such
animal. windows belong to the main thread. What you can do is fire a window
form and have your main thread pole the child thread to see if it is
finished. When it is, you can take down the window.

--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

<an***********@yahoo.com> wrote in message
news:eW**************@TK2MSFTNGP11.phx.gbl...
Hi to everybody,

I have the following situation:
I have a lengthy operation inside a desktop application - something that has to be executed on the main thread of the app (this is a must)
...
server.callLennghtyOperation(...)
...
While this operation is executing, I'd like to show a Form (practically a
modal form, that permits no access to the other forms of the application),
just to inform the user about the fact that the operation is being procesed.
Please can you give some ideeas how to do this.

I was thinkin on starting a thread just before the operation, that outputs a form (well, still got the problem that it has to behave as a modal
window!!!), and after the operation completes signaling the thread that the it can stop.
I am v much thinking in plain win api terms, being still new to .net.

Thanks in advance,
Andrea

Mar 7 '06 #2
well, but how to make the threaded window look "modal"?
"Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl...
a threaded modal window is a bit of a misnomer, there really is no such
animal. windows belong to the main thread. What you can do is fire a
window
form and have your main thread pole the child thread to see if it is
finished. When it is, you can take down the window.

--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

<an***********@yahoo.com> wrote in message
news:eW**************@TK2MSFTNGP11.phx.gbl...
Hi to everybody,

I have the following situation:
I have a lengthy operation inside a desktop application - something that

has
to be executed on the main thread of the app (this is a must)
...
server.callLennghtyOperation(...)
...
While this operation is executing, I'd like to show a Form (practically a
modal form, that permits no access to the other forms of the
application),
just to inform the user about the fact that the operation is being

procesed.

Please can you give some ideeas how to do this.

I was thinkin on starting a thread just before the operation, that
outputs

a
form (well, still got the problem that it has to behave as a modal
window!!!), and after the operation completes signaling the thread that

the
it can stop.
I am v much thinking in plain win api terms, being still new to .net.

Thanks in advance,
Andrea


Mar 7 '06 #3
Andrea,

You must take this as a suggestion of something that might work as I haven’t
had experience in this area and (against good practice) haven’t tried what
I’m suggesting.

You should be able to display any form modally by calling the form’s
ShowDialog() method (Show() would display the same form modelessly) and your
requirement that the lengthy operation takes place on the main thread means
you will know when it finishes simply because it has returned. Therefore, why
not define a simple form with a “Please Wait…” message and an okay button and
do this:

// Set up form
WaitForm form = new WaitForm();
form.okayButton.Enabled = false;
form.Cursor = Cursors.WaitCursor;
form.ShowDialog();

// Perform Operation
server.callLengthyOperation(…)

// Allow user to dismiss modal form
form.okayButton.Enabled = true;
form.Cursor = Cursors.Default;

You might well be able to lose the okay button and dismiss the form simply
by calling form.Close(). And of course, if you use the button, you can just
set Enabled to false in the designer rather than every time you instantiate
the form – I just did it that way to make it explicit. Same goes for the
pointer (or cursor in .net parlance).

You may have some scope problems to deal with in my ‘code’.

You mention threading the new form. Alvin has suggested that you can’t open
windows on a new thread and you say you can’t have your server call on a
different one. It looks like you’re stuck with a code topology at least
similar to mine, but unless you need any user interaction with the modal form
while the server call is progressing, I don’t see why it should matter.

Cheers,
Mike
"an***********@yahoo.com" wrote:
Hi to everybody,

I have the following situation:
I have a lengthy operation inside a desktop application - something that has
to be executed on the main thread of the app (this is a must)
....
server.callLennghtyOperation(...)
....
While this operation is executing, I'd like to show a Form (practically a
modal form, that permits no access to the other forms of the application),
just to inform the user about the fact that the operation is being procesed.

Please can you give some ideeas how to do this.

I was thinkin on starting a thread just before the operation, that outputs a
form (well, still got the problem that it has to behave as a modal
window!!!), and after the operation completes signaling the thread that the
it can stop.
I am v much thinking in plain win api terms, being still new to .net.

Thanks in advance,
Andrea

Mar 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Patrick Lim | last post by:
Here is the problem: I have written a non-modal frame class in Java for displaying help text when a user is using an application. It works as desired in that if the user selects "help" again,...
1
by: amith | last post by:
Hi, I have a javascript, calendar.js which i use to enable my client to select the date. This calendar pops up on the click of a gif image. But the problem is that this poped up window is not...
2
by: Matt | last post by:
I want to know how to submit the form data to a modal dialog window? The following is page1.asp, and when the user clicks submit button, it will post the form data to page2.asp by opening a new...
1
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of...
2
by: bob | last post by:
Hello, In my appliction I try to pop up a progress dialog box while an analysis is being run: //method progress window public void Run(IWin32Window parent) { Thread analysisThread = new...
5
by: CaptainZ | last post by:
When I open a modal window using 'showModalDialog' from an aspx page it works fine. But when I then perform a submit in my modal window to get data from the server, instead of the page returning to...
4
by: Todd | last post by:
I've got a situation where I need to display a modal dialog from within a background processing thread. The problem I'm having is that it needs to display as a modal window to the thread's parent...
2
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the...
4
by: John Kotuby | last post by:
Hi all... I am bulding an application and wish to use custom Modal dialog windows. According to a couple of recent articles I have seen, the newer Mozilla browsers (actually I think they said...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.