Is there a pause command?

T

Trint Smith

I need to pause one second here-|
|
|
Try |
<--------------------
conn.Open()
Dim sqlInsertCommand2 As New SqlCommand(sqlstr, conn)

How can I do that please?
thanks,
Trint

.Net programmer
(e-mail address removed)

.Net programmer
(e-mail address removed)
 
A

Armin Zingler

Trint Smith said:
I need to pause one second here-|
|
|
Try |
<--------------------
conn.Open()
Dim sqlInsertCommand2 As New SqlCommand(sqlstr, conn)

How can I do that please?

System.Threading.Thread.Sleep(1000)
 
R

Ray Cassick \(home\)

By more of a question is WHY do they NEED to sleep there for 1 second?

???
 
J

Jeff Brown

I found this , hope it helps

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Try
Sleep 1000
conn.Open()
Dim sqlInsertCommand2 As New SqlCommand(sqlstr, conn)
 
J

Jay B. Harlow [MVP - Outlook]

Jeff,
Unfortunately you got the define wrong, in .NET its:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)

Remember in VB.NET an Integer is 32 bits, a Long is 64 bits.

Also as Armin & Herfried showed, that API is already in .NET, no need to use
a Declare statement.

System.Threading.Thread.Sleep

The added advantage of the .NET version is it has the Integer version that
accepts milliseconds, plus a TimeSpan version that you can specify Hours,
Minutes, Seconds, and Milliseconds amounts with.

Hope this helps
Jay
 
T

Trint Smith

thanks,
this worked:
System.Threading.Thread.Sleep(1000)

and the reason I needed it is because of a function prior too this...for
some unexplicable reason, needs time to let go of a file...
thanks,
Trint

.Net programmer
(e-mail address removed)
 
F

Francis Ingels [MSFT]

A more robust solution might be:

Dim i As Integer = 0

While i < (Max Number of tries)
If ( Check for file access here) Then
Exit For
End If
i += 1
System.Threading.Thread.Sleep(1000)
End While
If i = ( Max number of tries) Then
'Take appropriate action on error
End If

In general, pausing for any set period to solve a timing issue is asking
for trouble.

Francis Ingels
Visual Studio Update


--------------------
 
F

Francis Ingels [MSFT]

The 'Exit For' should be 'Exit While'

Francis Ingels
Visual Studio Update

--------------------
Newsgroups: microsoft.public.dotnet.languages.vb
From: ringels@subtract_this_field.microsoft.com (Francis Ingels [MSFT])
Organization: Microsoft
Date: Tue, 07 Oct 2003 18:55:47 GMT
Subject: Re: Is there a pause command?
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

A more robust solution might be:

Dim i As Integer = 0

While i < (Max Number of tries)
If ( Check for file access here) Then
Exit For
End If
i += 1
System.Threading.Thread.Sleep(1000)
End While
If i = ( Max number of tries) Then
'Take appropriate action on error
End If

In general, pausing for any set period to solve a timing issue is asking
for trouble.

Francis Ingels
Visual Studio Update


--------------------
From: Trint Smith <[email protected]>
References: <efQS#[email protected]>
X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
Subject: Re: Is there a pause command?
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
Date: Tue, 07 Oct 2003 11:17:47 -0700
NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
Lines: 1
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:144656
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

thanks,
this worked:
System.Threading.Thread.Sleep(1000)

and the reason I needed it is because of a function prior too this...for
some unexplicable reason, needs time to let go of a file...
thanks,
Trint

.Net programmer
(e-mail address removed)
 

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