473,785 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.callLenn ghtyOperation(. ..)
....
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 1374
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******** ******@TK2MSFTN GP11.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.callLenn ghtyOperation(. ..)
...
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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP11.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.callLenn ghtyOperation(. ..)
...
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.WaitCur sor;
form.ShowDialog ();

// Perform Operation
server.callLeng thyOperation( )

// 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.callLenn ghtyOperation(. ..)
....
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
3629
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, the same frame is used -- this is done using a singleton. The user can do other stuff in the main window while the help window is up. However, when I have a modal dialog pop-up to get information from the user, it blocks events to the help...
1
12532
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 modal in nature(i do not want the user to go the parent page unless he selects some date in the calendar popup). In the javascript calendar.js he has used window.open() function to pop up the window. i just want to know whether we have any...
2
3885
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 window. But I want modal dialog window, any ideas?? <form action="page2.asp" method="post" target="_blank"> <input type="text" name="username"> <input type="submit" name="submit"> </form>
1
3373
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 normal window. Actually, I tried to close the parent window from the child modal window using parent.close syntax in onload event in child modal window. It actually closes the parent modal window, but the child modal window is not opened, why it is...
2
6436
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 Thread(new ThreadStart(runAnalysis)); analysisThread.Start();
5
2496
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 the modal window with the new data the server creates a new, non-modal, window - leaving the modal window in the state it was and another, unrelated copy open with the requested data in it Can I get the data to return to the original modal window...
4
1371
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 GUI app. When I try this I get a pseudo-modal dialog (more like a top-level window)... the dialog is always on top of the parent app's window, but the user can still access the parent window and its controls. Is there any way to accomplish...
2
3688
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 dialog. To be more specific I want to have a confirmation dialog that is shown when a user clicks on a Delete button (which deletes some values from database). If Yes is pressed the delete action is processed otherwise modal dialog is closed.
4
10636
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 Netscape) supported syntax like : window.open(URL ,"diagwin","modal=1, width=30"); For IE I use : window.showModalDialog
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10098
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.