Connecting Tech Pros Worldwide Forums | Help | Site Map

sleep methods in vb.net

Jason
Guest
 
Posts: n/a
#1: Nov 21 '05
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




Oenone
Guest
 
Posts: n/a
#2: Nov 21 '05

re: sleep methods in vb.net


Jason wrote:[color=blue]
> How do I implement the sleep method?[/color]

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

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

Hope that helps,

--

(O) e n o n e


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#3: Nov 21 '05

re: sleep methods in vb.net


"Jason" <someone@somewhere.com> schrieb:[color=blue]
> 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.[/color]

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Tom Shelton
Guest
 
Posts: n/a
#4: Nov 21 '05

re: sleep methods in vb.net


In article <#rQ6CzhZFHA.2996@TK2MSFTNGP10.phx.gbl>, Jason wrote:[color=blue]
> 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
>[/color]

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.

--
Tom Shelton [MVP]
Cor Ligthert
Guest
 
Posts: n/a
#5: Nov 21 '05

re: sleep methods in vb.net


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


Closed Thread


Similar Visual Basic .NET bytes