sleep methods in vb.net

J

Jason

In a vbscript making something sleep is as easy as this....
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5000

In .net I've got the object created. I know it works because I use it else
where.
Set WshShell = CreateObject("WScript.Shell")

How do I implement the sleep method?

What I'm doing is using the WshShell to run/open the remote assistance help
page, and then I use SendKeys to populate the pc name field, however I need
a delay before the sendkeys call since depending on the pc, the remote
assistacne page may take a sec or two to open. So if you sendkeys before
the app is ready the key strokes wont get there.

Thanks
 
O

Oenone

Jason said:
How do I implement the sleep method?

I'd use the .NET Thread.Sleep() method instead of using WScript. Try this:

\\\
Threading.Thread.CurrentThread.Sleep(5000)
///

Hope that helps,
 
H

Herfried K. Wagner [MVP]

Jason said:
however I need
a delay before the sendkeys call since depending on the pc, the remote
assistacne page may take a sec or two to open.

\\\
Imports System.Threading
..
..
..
Thread.Sleep(1000)
///
 
T

Tom Shelton

In a vbscript making something sleep is as easy as this....
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5000

In .net I've got the object created. I know it works because I use it else
where.
Set WshShell = CreateObject("WScript.Shell")

How do I implement the sleep method?

What I'm doing is using the WshShell to run/open the remote assistance help
page, and then I use SendKeys to populate the pc name field, however I need
a delay before the sendkeys call since depending on the pc, the remote
assistacne page may take a sec or two to open. So if you sendkeys before
the app is ready the key strokes wont get there.

Thanks

You can as, the other posters indicated use
System.Threading.Thread.Sleep.

I'm wondering though, if it might not be possilbe to launch this using
the System.Diagnostics.Process class... If you could, then you would be
able to use the process instance method, WaitForInputIdle - which
basically, waits until the launched process is ready to begin accepting
input.
 
C

Cor Ligthert

Jason,

In addition to Tom, can you not use the standardoutput member to get the
output from the process. (even if it is the end).

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top