Connecting Tech Pros Worldwide Forums | Help | Site Map

Program Startup

John Wright
Guest
 
Posts: n/a
#1: Jul 17 '08
During my program startup I need to check for a couple of things.
1. I need to check for network availability
2. I need to check for database connectivity
3. I need to check for access to the server via a webservice

I have written the code to do all of these things. Now I want to put them
into a startup form. I want to load my main form, but from the main form I
want to call a splash screen with an animation on it that will cycle through
all the above events. This will let the user know there is action going on.
Also, if the network or database connection fails, I want to prevent them
from using the program or store the files locally. If the server cannot be
accessed, I will write the data to the database then process later. Again
the code for these actions are done. What I need is a really good way of
showing a splash screen, update a label on the splash screen while checking
for these items, then close the splash screen.

I can load the splash screen as follows

Dim mySplash as new splashScreen
mySplash.Show

This will show the screen, but I need suggestions to update the label on the
screen while checking for the items above. Anyone have a good idea or can
point me to an article on a good way to use a splash screen?

Thanks.

John



rowe_newsgroups
Guest
 
Posts: n/a
#2: Jul 17 '08

re: Program Startup


On Jul 17, 1:43*pm, "John Wright" <riley_wri...@hotmail.comwrote:
Quote:
During my program startup I need to check for a couple of things.
* * 1. *I need to check for network availability
* * 2. *I need to check for database connectivity
* * 3. *I need to check for access to the server via a webservice
>
I have written the code to do all of these things. *Now I want to put them
into a startup form. *I want to load my main form, but from the main form I
want to call a splash screen with an animation on it that will cycle through
all the above events. *This will let the user know there is action going on.
Also, if the network or database connection fails, I want to prevent them
from using the program or store the files locally. *If the server cannot be
accessed, I will write the data to the database then process later. *Again
the code for these actions are done. *What I need is a really good way of
showing a splash screen, update a label on the splash screen while checking
for these items, then close the splash screen.
>
I can load the splash screen as follows
>
Dim mySplash as new splashScreen
mySplash.Show
>
This will show the screen, but I need suggestions to update the label on the
screen while checking for the items above. *Anyone have a good idea or can
point me to an article on a good way to use a splash screen?
>
Thanks.
>
John
If it were me, I'd start the application from a module using Sub
Main(), show the splash screen, and pop events from the module that
the splash screen would subscribe to. These events would contain the
text to display on the splash screen and any other applicable data.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
John Wright
Guest
 
Posts: n/a
#3: Jul 17 '08

re: Program Startup


Okay,

I set up a sub main to run and raised events. I subscribed to these events
in the form using event handlers. I simulated the connections and ran. I
got the outline of the form which appears while the process runs then it
goes away.

So I tried a background worker thread with the same results. Do I need to
refresh the form? How can I show the form all the way on a load like this?

John
"John Wright" <riley_wright@hotmail.comwrote in message
news:eYxyVSD6IHA.1200@TK2MSFTNGP04.phx.gbl...
Quote:
During my program startup I need to check for a couple of things.
1. I need to check for network availability
2. I need to check for database connectivity
3. I need to check for access to the server via a webservice
>
I have written the code to do all of these things. Now I want to put them
into a startup form. I want to load my main form, but from the main form
I want to call a splash screen with an animation on it that will cycle
through all the above events. This will let the user know there is action
going on. Also, if the network or database connection fails, I want to
prevent them from using the program or store the files locally. If the
server cannot be accessed, I will write the data to the database then
process later. Again the code for these actions are done. What I need is
a really good way of showing a splash screen, update a label on the splash
screen while checking for these items, then close the splash screen.
>
I can load the splash screen as follows
>
Dim mySplash as new splashScreen
mySplash.Show
>
This will show the screen, but I need suggestions to update the label on
the screen while checking for the items above. Anyone have a good idea or
can point me to an article on a good way to use a splash screen?
>
Thanks.
>
John
>

rowe_newsgroups
Guest
 
Posts: n/a
#4: Jul 17 '08

re: Program Startup


On Jul 17, 3:34*pm, "John Wright" <riley_wri...@hotmail.comwrote:
Quote:
Okay,
>
I set up a sub main to run and raised events. *I subscribed to these events
in the form using event handlers. *I simulated the connections and ran.*I
got the outline of the form which appears while the process runs then it
goes away.
>
So I tried a background worker thread with the same results. *Do I needto
refresh the form? *How can I show the form all the way on a load like this?
>
John"John Wright" <riley_wri...@hotmail.comwrote in message
>
news:eYxyVSD6IHA.1200@TK2MSFTNGP04.phx.gbl...
>
Quote:
During my program startup I need to check for a couple of things.
* *1. *I need to check for network availability
* *2. *I need to check for database connectivity
* *3. *I need to check for access to the server via a webservice
>
Quote:
I have written the code to do all of these things. *Now I want to putthem
into a startup form. *I want to load my main form, but from the main form
I want to call a splash screen with an animation on it that will cycle
through all the above events. *This will let the user know there is action
going on. Also, if the network or database connection fails, I want to
prevent them from using the program or store the files locally. *If the
server cannot be accessed, I will write the data to the database then
process later. *Again the code for these actions are done. *What I need is
a really good way of showing a splash screen, update a label on the splash
screen while checking for these items, then close the splash screen.
>
Quote:
I can load the splash screen as follows
>
Quote:
Dim mySplash as new splashScreen
mySplash.Show
>
Quote:
This will show the screen, but I need suggestions to update the label on
the screen while checking for the items above. *Anyone have a good idea or
can point me to an article on a good way to use a splash screen?
>
Quote:
Thanks.
>
Quote:
John
The problem is most likely that your connectivity checks are occurring
too fast, you'll probably need to add in some logic to keep the splash
screen showing for a while. Before doing anything heavy duty, you
could try opening the form on a seperate thread and then doing a
Thread.Sleep(1000) between the connectivity checks in Sub Main. If
that works you can look at writing the long term solution.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
John Wright
Guest
 
Posts: n/a
#5: Jul 17 '08

re: Program Startup


Here is the code that is doing the checks on the form:

Threading.Thread.Sleep(4000)

CheckNetwork()

Threading.Thread.Sleep(4000)

CheckDB()

Threading.Thread.Sleep(4000)

CheckEPN()

Threading.Thread.Sleep(4000)

My.Forms.frmMain.Show()

I am doing a sleep for 4 seconds between calls. Also, when I load the form,
the animation loads just fine, but the first call to the method that updates
the label freezes the animation and the form until it is loaded. I'll just
keep plugging at it I guess.



John

"rowe_newsgroups" <rowe_email@yahoo.comwrote in message
news:9d24a051-328a-46a2-9a02-95299ba82337@c58g2000hsc.googlegroups.com...
On Jul 17, 3:34 pm, "John Wright" <riley_wri...@hotmail.comwrote:
Quote:
Okay,
>
I set up a sub main to run and raised events. I subscribed to these events
in the form using event handlers. I simulated the connections and ran. I
got the outline of the form which appears while the process runs then it
goes away.
>
So I tried a background worker thread with the same results. Do I need to
refresh the form? How can I show the form all the way on a load like this?
>
John"John Wright" <riley_wri...@hotmail.comwrote in message
>
news:eYxyVSD6IHA.1200@TK2MSFTNGP04.phx.gbl...
>
Quote:
During my program startup I need to check for a couple of things.
1. I need to check for network availability
2. I need to check for database connectivity
3. I need to check for access to the server via a webservice
>
Quote:
I have written the code to do all of these things. Now I want to put
them
into a startup form. I want to load my main form, but from the main form
I want to call a splash screen with an animation on it that will cycle
through all the above events. This will let the user know there is
action
going on. Also, if the network or database connection fails, I want to
prevent them from using the program or store the files locally. If the
server cannot be accessed, I will write the data to the database then
process later. Again the code for these actions are done. What I need is
a really good way of showing a splash screen, update a label on the
splash
screen while checking for these items, then close the splash screen.
>
Quote:
I can load the splash screen as follows
>
Quote:
Dim mySplash as new splashScreen
mySplash.Show
>
Quote:
This will show the screen, but I need suggestions to update the label on
the screen while checking for the items above. Anyone have a good idea
or
can point me to an article on a good way to use a splash screen?
>
Quote:
Thanks.
>
Quote:
John
The problem is most likely that your connectivity checks are occurring
too fast, you'll probably need to add in some logic to keep the splash
screen showing for a while. Before doing anything heavy duty, you
could try opening the form on a seperate thread and then doing a
Thread.Sleep(1000) between the connectivity checks in Sub Main. If
that works you can look at writing the long term solution.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/


Steve Gerrard
Guest
 
Posts: n/a
#6: Jul 18 '08

re: Program Startup


John Wright wrote:
Quote:
>
I am doing a sleep for 4 seconds between calls. Also, when I load
the form, the animation loads just fine, but the first call to the
method that updates the label freezes the animation and the form
until it is loaded. I'll just keep plugging at it I guess.
>
If you put the UI thread to sleep for 4 seconds, and otherwise keep it busy with
your checks, then yes, the form will never have a chance to paint.

If you just want to update a label, do a mySplash.Refresh. If there is some sort
of animation that is supposed to run on the splash, then you would need to do
the checks on a background thread.



John Wright
Guest
 
Posts: n/a
#7: Jul 22 '08

re: Program Startup


Got it to work. Here is what I did.

On my splash screen I created the following:
Public Delegate Sub UpdateStatusDelegate(ByVal Status As String, ByVal
progress As Integer)

Then I created the following Sub on the splash screen to call:

Public Sub UpdateStatus(ByVal status As String, ByVal progress As Integer)

If Me.InvokeRequired Then

Me.Invoke(New UpdateStatusDelegate(AddressOf Me.UpdateStatus), New Object()
{status, progress})

Else

Me.lblStatus.Text = status

Me.ProgressBar1.Value = progress

End If

Me.Refresh()

End Sub

Then from the main form I call as follows (to simulate the load for now, I
will call the updatestatus as I load):

EPNSplash.Show()

EPNSplash.UpdateStatus("Starting EPN...", 20)

Threading.Thread.Sleep(3000)

EPNSplash.UpdateStatus("Checking Network...", 40)

Threading.Thread.Sleep(3000)

EPNSplash.UpdateStatus("Checking Database...", 60)

Threading.Thread.Sleep(3000)

EPNSplash.UpdateStatus("Connecting to EPN system...", 80)

Threading.Thread.Sleep(3000)

EPNSplash.UpdateStatus("Program loaded.Initializing...", 100)

Threading.Thread.Sleep(3000)

EPNSplash.Close()

Works like a charm. Thanks one and all for the help.



John


Closed Thread