|
-
Jun 23rd, 2004, 06:28 AM
#1
Thread Starter
Hyperactive Member
Is there a delay() command of some sort in vb.net?
I need to delay program execution for a few seconds...
i.e
' Do stuff here
' delay for 5 seconds
' continue here
How can I do this?
-
Jun 23rd, 2004, 07:07 AM
#2
VB Code:
System.Threading.Thread.Sleep(666)
-
Jun 23rd, 2004, 07:11 AM
#3
Thread Starter
Hyperactive Member
Thanks, you're probly wondering why I would want to do this. Maybe you have a better idea. How can I run a loop until a service has been installed?
i.e
Dim sc as New ServiceController("MyService")
do until sc.exists()\
loop
But I can't find anything similar in the real world...
-
Jun 23rd, 2004, 08:10 AM
#4
Frenzied Member
Look into the ServiceControlller's WaitForStatus functionality.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 23rd, 2004, 08:29 AM
#5
Thread Starter
Hyperactive Member
Problem is an exception is thrown when I call the serviceController object.
I wrote a function that returns true if no exception is thrown and false if an exception is thrown to check if the service is installed, but was wondering if there's a better way to do this...
-
Jun 23rd, 2004, 08:39 AM
#6
Frenzied Member
Can you give us some source code of what you are trying to do?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 23rd, 2004, 08:51 AM
#7
Thread Starter
Hyperactive Member
Well,
All I'm doing is installing some third party services, and then trying to start them once they are installed.
The problem has been though that the app tries to start the service before its been installed. So If I create a service object i.e
Dim sc as New ServiceController("MyService")
And I try to reference the object, an exception is thrown.
What I ultimately want to do is check if the service is installed without throwing an exception.
But what I have done, which works is run a function that throws false if an exception occurs when it checks the service.
Any better way to do this?
-
Jun 23rd, 2004, 09:06 AM
#8
Frenzied Member
Well, you could put a loop in there with some sleeps....
...try to create the ServiceController, catch any exceptions, if it excepted, sleep ten seconds and try again until you get success or a maximum amount of interations have occurred...
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|