473,385 Members | 1,344 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,385 software developers and data experts.

Show a from immediately

Dom
On my main form, I click a button to bring up a second form. When the
second form comes up, I want to do the following:

1. change this.Cursor to Cursors.Wait
2. Execute the EnumerateServers (or whatever) method.
3. Add all Server names to a list box.
4. Change this.Cursor back again.

The reason for steps 1 and 4 is that step 2 can take so long. Of
course, all of this makes sense only if the user can actually see the
form. I've placed all the code in the Load event, but the user just
sees the border of the form for several seconds, making him think
something is going wrong. Same thing with the Activate event. Where
should I place it?

May 14 '07 #1
7 1691
Dom,

What you should do on the Load event is to kick off a thread (using the
Thread class, or through the ThreadPool) which will perform the enumeration
for you. Then, when the task is done, you can call the Invoke method on the
main form to indicate that the operation is complete.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dom" <do********@gmail.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
On my main form, I click a button to bring up a second form. When the
second form comes up, I want to do the following:

1. change this.Cursor to Cursors.Wait
2. Execute the EnumerateServers (or whatever) method.
3. Add all Server names to a list box.
4. Change this.Cursor back again.

The reason for steps 1 and 4 is that step 2 can take so long. Of
course, all of this makes sense only if the user can actually see the
form. I've placed all the code in the Load event, but the user just
sees the border of the form for several seconds, making him think
something is going wrong. Same thing with the Activate event. Where
should I place it?

May 14 '07 #2
"Dom" <do********@gmail.comschrieb im Newsbeitrag
news:11**********************@u30g2000hsc.googlegr oups.com...
On my main form, I click a button to bring up a second form. When the
second form comes up, I want to do the following:

1. change this.Cursor to Cursors.Wait
2. Execute the EnumerateServers (or whatever) method.
3. Add all Server names to a list box.
4. Change this.Cursor back again.
You have to split that tasks.
In the Load event you should execute step 1 and then start a Thread that
executes Step 2. This Thread must somehow provide the result (the names of
the server + whatever additional information needed). This Thread may not
access the UI.
At the end, the thread should use the Invoke-method of the Form to invoke
the execution of step 3 and step 4. This will push the execution of this
steps to the GUI.

Additional the thread can use Invoke to show some intermediate result, like
filling the list box as the results are recieved or showing process.

So far
Christof
May 15 '07 #3
If you don't want or need to start threading, you should be able to simply
do this in the Form Load event:
1. change this.Cursor to Cursors.Wait
Me.Show()
Application.DoEvents()
2. Execute the EnumerateServers (or whatever) method.
3. Add all Server names to a list box.
4. Change this.Cursor back again.
/Johnny J.
"Dom" <do********@gmail.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
On my main form, I click a button to bring up a second form. When the
second form comes up, I want to do the following:

1. change this.Cursor to Cursors.Wait
2. Execute the EnumerateServers (or whatever) method.
3. Add all Server names to a list box.
4. Change this.Cursor back again.

The reason for steps 1 and 4 is that step 2 can take so long. Of
course, all of this makes sense only if the user can actually see the
form. I've placed all the code in the Load event, but the user just
sees the border of the form for several seconds, making him think
something is going wrong. Same thing with the Activate event. Where
should I place it?

May 15 '07 #4
"Johnny Jörgensen" <jo**@altcom.seschrieb im Newsbeitrag
news:Om**************@TK2MSFTNGP03.phx.gbl...
If you don't want or need to start threading, you should be able to simply
do this in the Form Load event:
>1. change this.Cursor to Cursors.Wait

Me.Show()
Application.DoEvents()
>2. Execute the EnumerateServers (or whatever) method.
<snip>

That wouldn't help much. While step 2, the GUI will still be blocked,
including PaintEvents. So after putting some other apps form in front of it,
it wouldn't repaint itself until after step 2 finished.

Christof
May 15 '07 #5
Dom
On May 15, 3:46 am, "Johnny Jörgensen" <j...@altcom.sewrote:
If you don't want or need to start threading, you should be able to simply
do this in the Form Load event:
1. change this.Cursor to Cursors.Wait

Me.Show()
Application.DoEvents()
I'm in CSharp, not VB. There is no DoEvents, right?

May 15 '07 #6
Sadly, there is. As per the example, it is a static method on
Application; this is what VB uses under the bonnet, so there is no
real difference. I'm not sure I'd recommend it in a production app,
though ;-p

Marc
May 15 '07 #7
On May 14, 5:20 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
What you should do on the Load event is to kick off a thread (using the
Thread class, or through the ThreadPool) which will perform the enumeration
for you. Then, when the task is done, you can call the Invoke method on the
main form to indicate that the operation is complete.
A background worker component would make this even easier.

May 15 '07 #8

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

Similar topics

77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
10
by: David | last post by:
Hi everyone, Hoping there are some .js/browser experts out there that can help with this weird problem. I have made a swap div routine and applied the events to menu buttons with a closer...
3
by: ad | last post by:
I want user can confirm before delete records ? How can I show a confirm dialog when users press a button?
2
by: WStoreyII | last post by:
I have a class that is sort of a custom console it has an object member in this class that is a custom form with a sub show which has a command of frm.sho my question is i had a module with a...
9
by: twnety0ne | last post by:
Hey guys, I have multiple forms in my windows app, and in my startup form i am doing the following in order to navigate to a different form: Dim myform as New frmsecondform...
3
by: Yves Glodt | last post by:
Hi, I have a mainwindow in my pyqt application, and on click of a button I want to start an assistant (wizard). I have create the wizard with the Qt Designer, generated the python code with...
1
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
1
by: mervyn | last post by:
Hi There, I have recently started coding in ASP.NET (less than 2 weeks) and over the last day or 2 I've started using some Javascript. I have created a screen with a table and xx number of rows....
3
by: Dominique | last post by:
Hello, Sorry bothering you with such a trivial problem. I installed python on a new mac at office. It seems everything is fine: in the console, I access to python. But I just can't start...
1
by: mumbaisalsa | last post by:
hi all, i want to run the slide show say ten slides and then close it , but in my code given below it opens the slide show and closes immediately ... .. please give me a solution to this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.