Sleep Little Thread, Sleep
Hi out there.
I'm getting stupid! I created a new thread. The thread calls a function which sets a textbox on a form to current time. Works well but my cpu is running 100%. No question cause there is a do ... loop with text1 = time$ inside. Going forward i inserted a sleep(500) into the loop. Guess what happened? The app crashed. Now tell my why. I tried everything. Any ideas?
Public Function threadDO() Do Sleep 500 Form1.text1 = time$ Loop End Function
Yours
buzz
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Threading.thread.sleep In Vb6
is vb6 allow sleep method?? it doesnt same wif vb.net--> threading.thread.sleep(2000)..can anyone show me how is it in vb6??
Sleep Without Suspending The Thread
OK - what I need to do is to sleep without suspending the thread on which the VB code is executing.
The API call 'Sleep' actually suspends the execution of the thread at the O/S which is totally unacceptable.
Using a null instruction loop uses 100% CPU which invokes all sorts of thread context switching which is undesirable.
Adding DoEvents makes the VB function reentrant which is totally unacceptable.
What I need to do is to pause the VB code execution for a small, random, amount of time (10-100ms)
Any ideas?
Can I Use Sleep API Function In Thread Function
Hi all
i am trying to use sleep API function within the body of the thread functio, but i can't an error occur
for example
Private Sub Command1_Click()
hThread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf th1, ByVal 0&, ByVal 0&, hThreadID1)
End Sub
Public Sub th1()
While (True)
Form1.Label1.Caption = Val(Form1.Label1.Caption) + 1
Sleep(1000) ' the error occur when sleep function end
Wend
End Sub
also u must note that when i run the program from the VB its work probably, but when i make an EXE file and run it ... the errors occur
the error messege is:
The instruction at "0x6aaa7339" referenced memory at "0x0000009c". The memory could not be "written".
...
Help With Sleep
i wanted to "deal" one card at a time (load pictures) by using the sleep function in between but when i do that it doesnt go smoothly because by the time the 1 picture loads it is already "sleeping" so it looks like it froze
is there any other "pause" or wait comand that i can use that just takes up time in the program instead of freezing it?
Sleep Not Available In VB 6.0 ?
I like to run trough a while loop every second util the wile exists.
So i need to sleep my program a second in the loop.
But Sleep(1000) doesn't work
How can i do that?
While Not (Dir$("C:Program Fileslijst.pdf") <> "")
Sleep (1000)
MsgBox ("Nog niets gevonden")
Wend
Sleep API
What are the API's to be called for the SLEEP command??
Sorry, I found it.
Declare Sub Sleep Lib "kernel32" Alias "Sleep" _
(ByVal dwMilliseconds As Long)
Mods delete this thread or let it die.
Sleep?
hi all,
I am looking for a way to make a Vbprogram pause for a certain number of milliseconds. e.g.
While (condition)
Sleep (500 millisecs)
[statements]
Wend
Whats the easiest way to do this....
if i do:
While(condition)
Wend
The program freezes.
Sleep
Why will my code not sleep???
Code:
strComputer = "."
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", "Admin2")
objUser.SetPassword "test"
objUser.SetInfo
sleep 3000
strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/Admin2,user")
objGroup.Add(objUser.ADsPath)
Sleep
Quote:
Originally posted by Ad1
check out the SetSystemPowerState API, if you don't already have it then I recommend you download the API Guide
Ad1, do you know if Windows 2000 is the only version of NT that supports power-saving features? The compatibility for the API is "Requires Windows 2000 or later; Requires Windows 95 or later", and I was wondering if I would need to use a different API if power-saving features are supported on NT 4
Sleep
is there any simple code that will put the computer into sleep mode??
Sleep
How can i make my program sleep for a few seconds. I would like to let my splash-screen appear for more one 1 ms.
No Sleep !
I am in a middle of a loop and need to pause the application for 10 sexonds.
Unfortunately, using the Sleep() will hang my application for 10 seconds
Is there any better idea than Sleep ?!
Thanks.
Help With SLEEP
First of all, I am using VB6 on an NT platform. I wrote a simple VB6 routine to run an FTP job every 12 hours, transferring a text file from an old unix server to my pc. I have been able to run the FTP successfully in other programs and it works perfectly when I add the SLEEP. Every 12 hours, the routine runs, yet when this program is SLEEPing in the background it interferes with the logon process of a unix inventory tool. As soon as I shut down my VB program, the unix tool allows me to logon. So, each operates perfectly independant of one another, but the VB routine somehow is causing a problem.
I can, however, logon to the unix tool first, then run my VB FTP routine and both work fine, but if I start up my VB FTP program first, the unix tool won't let me logon.
Here is how my SLEEP is declared:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Here is how my SLEEP is used:
Call Sleep(43200000)
Has anyone else had a problem like this, and is there a fix? Any guesses at to what the problem is? Is there a replacement I can use in place of SLEEP? Any help would be appreciated.
Thanks,
VisualBasicUser
P.S. By using my "Task Manager", I can tell that my VB6 program is NOT causing excessive memory or processor usage (nor is the Unix tool), so that can't be the problem.
Sleep
Is there like a sleep/pause function in vb ?
Thank You,
Sleep
I am trying to use sleep, but it does not seem to work (sub or function not defined). Are there any alternatives?
sleep 100
Sleep()?
I am looking for something like the sleep() command in other languages. Want my code to pause for a set(-able) time, without having to rebuild my whole application to use the timer-object.
Thanks for your help!!!
Borniet
Sleep
If found a code using this
VB Code:
Declare Function GetTickCount Lib "kernel32" () As Long 'PausePublic Sub Pause(HowLong As Long) Dim u%, tick As Long tick = GetTickCount() Do u% = DoEvents Loop Until tick + HowLong < GetTickCountEnd Sub
to pause,
so what is the different between this and Sleep ?
which 1 is better..?
Cant Sleep!
Hi All,
Here is my code, I am running on Windows NT.
VB Code:
Private Declare Function Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Command1_Click() Sleep 100MsgBox "Done" End Sub
However, it crashes at the sleep command. Is there any reason why this isn't working?? It works through Perl without any problems.
Cheers!
Paul.
Sleep API?
I have this other program, and I wanna freeze it for a period of time. How do I do this?
Sleep
What's the syntax for using the Sleep function in VB?
I know this is on here somewhere already, but since Search has been disabled I thought I'd ask again.
Sleep
Is there a code that will stop my code from executing for a couple seconds?
Like a Sleep function?
Thanks
Maybe I Need To Get Some Sleep But..
why do I keep getting a zero here ( rEs ), no matter what ?!!
Code:
Dim rEs As Long
Dim fOp As SHFILEOPSTRUCT
With fOp
.hWnd = hWnd
.wFunc = FO_DELETE
.pFrom = KlisT
.fFlags = FOF_FILESONLY Or FOF_ALLOWUNDO
End With
rEs = SHFileOperation(fOp)
Debug.Print rEs
Sleep
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
why does this cause a compile error when I have it in the declarations of my forms code. And if it's not supposed to go there, where does it go?
Cheers
Nick
Sleep?
Is there like a Sleep function, that waits how many seconds you tell it to, and then continues on with the code?
I know in QBasic you typed "Sleep 2" and it would wait 2 seconds, but no such luck with VB
Thanks.
Sleep
Hi,
In QBasic I recall a command to 'sleep' for a certain period of time. I have not programmed for a LONG time and I now need a little application to execute a file, then 'sleep' and execute it again with another variable (ie. file.exe 123, then 5 seconds later file.exe 111 etc.)
Being that I do not have a copy of VB or QB on this computer, does anyone know if something like this is possible with a batch (.bat) file? If it is not, does anyone know if it is possible in PHP (the PHP script actually calls the executable, so in essence I wouldnt need a batch file if the PHP could do the same thing...)?
If niether is an option, I guess I'll just get a copy of Basic and complie it as an exec.
Thanks,
Larry
Sleep
plz can some one send me sleep code with declaration
and if it use module form tel me how
thx
i try all way it't work
and i was 2 use this decration
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
kazanova
Sleep
Hi,
How can I "sleep" for a while in my program.
I don't want to do busy waiting.
Thanks.
Is There Sleep() ?
Is there a command for a timedelay (in milliseconds) in VB? Something like delay() or sleep()? I tried faking it with a loop while a timer makes some variable True, but the program just hangs. Thanx.
Sleep
Is there any command similar to VC's Sleep(int) command? Thanks for any advice!
How To Use Sleep In VB
Hello,
I have looked in MSDN but come away still wondering how to use the Sleep function with VB. Can anyone show an example?? Or is there a compatible function in VB that is easier to use?
Thanks,
Sean
About The Sleep Function
Hi, I don't know how to work the sleep function, is it something I have to define, or is it an API, I'm lost, if someone could please help, thanks
Loop Sleep
Hello,
I have a function that runs in a loop and the functions sends information to a control, then the control sends back information. I would like to give the control time to send back information before I run the function again the loop. Can I someone wait a second before running the function again?
Thanks!@#$
Sleep API Call
Hi,
I wanted to use the API call sleep, the declaration of it is below:
Code:
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
I read about it on AllAPI.net. It says "A value of INFINITE causes an infinite delay." for the parameter "dwMilliseconds".
Firstly how can I pass an infinite value to it & secondly is there anyway that I could cancel the infinite delay after i passed an infinite value to it.
Thanks in advance
App Sleep In Some Seconds?
hi all,
how can i make my application sleep (not working) in some seconds before do something else .
thanx.
Try To Use Timer Instead Of Sleep.....
My program used to have many sleep statements and the application will freeze then. Now I am using another delay function:
Public Sub Delay(lngSeconds As Long)
Dim lngStart As Long
lngStart = Timer
Do While Timer <= lngStart + lngSeconds
DoEvents
Loop
End Sub
But suppose I want to stop the application in the middle, I need to click stop button or just close the application. The problem is even I close the application, the process is still going. Anyway to make it really stop right there and quit whatever function the process is in?
thanks.
Question To SLEEP
Does SLEEP stop all activity of the computer for the choosen time?
Means - all multi-tasking-processes (if there are any) are stopped, too?
Sleep And SendKeys
I'm trying to use Sleep to delay between SendKeys and it's acting strange. I put code similar to the following:
AppActivate "HP Precisionscan Pro"
Sleep 500
SendKeys "[A bunch of keys]"
Sleep 500
SendKeys "[A bunch of keys]"
The program pauses after it activates the app but then it sends the keys from both SendKeys statements without pausing at all. Am I using the Sleep function wrong?
Sleep API Problem
Hi again, when I use the sleep API, where do I paste this line
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
into my code?
I've tried a number of different places, but I always get the same error:
Complie Error
Only comments may appear after End Sub, End Function or End Property
Please tell me what I'm doing wrong, thanks.
jonny
Sleep Function?
Is there a sleep function (or timer) in VB? Our program is working too fast!
Thanks!
Sleep Function
Hey dear kind people reading this...
HELP!!!
I want to have a delay in my program
But it won't work with a timer
So, I know I need to use the sleep function
But I don't know how
Could someone please help with the code, and explain what's going on if possible
Thanks so much!!!
Is There A Better Way I Could Write This(using Sleep)
the problem im having now is that i get vb to look into a pages source stored in txtSource then return what im looking for. but as the web page takes a couple of seconds to load my code has all ready cycled through so i dont get a value returned. I thought about using the sleep process to help. here is what iv got
Code:
Private Sub btnGet_Click()
On Error Resume Next
'Enable timers
Timer1.Enabled = True
Timer2.Enabled = True
Dim UserName
UserName = "http://www.squatjuice.com/cgi-bin/yabb/YaBB.pl?action=viewprofile;username=" & cboAddress.Text
If cboAddress = "" Then Exit Sub
WebBrowser1.Navigate UserName
Sleep (3000) 'Delays for 3 seconds
'contine you process
UserAvailable = IsUserOnline(txtSource)
If UserAvailable = online Then
MsgBox ("User Online")
End If
If UserAvailable = Offline Then
MsgBox ("User Offline")
End If
End Sub
the problem that im having is that the whole proces is paused for 3seconds. what i was hoping for is that it would run the first pice of code then sleep for 3seconds then continue. any suggestions???? i hope i explained this ok
DoEvents Or Sleep (API), Which Is Better?
just wanna know ur opinions/understanding regarding the two stuffs, DoEvents and Sleep(API).
which one is better? and for what application do i use each?
i have been using these two separately and i could see that SLEEP pumps CPU Usage lesser than DoEvents.
any opinions are welcome
Sleep And Events
Does the sleep API calls allows processing of events during the sleeping interval?
Sleep Problem
I'm using the sleep api in my program
--> Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
and whenever I use a sleep value of over about 50 it locks the program up and also the rest of my computer, but if I do a smaller value it works fine, problem is I want to sleep for 1000. I'm using it along with sendkeys so maybe thats whats causing it?
code looks like this:
sleep 1000
sendkeys "{ENTER}"
sleep 1000
sendkeys "{ENTER}"
sleep 1000
sendkeys "{ENTER}"
...
and so on, hitting enter about 20 times
I also tried it as a loop and it locks up that way too.
What the heck is going on, it should just pause the program not my whole system right? Help please!
Need Help With The Sleep Command
Hey, I've tried to use the sleep API to suspend my program for certain amount of time, but even though the sleep (number) is inside a button sub, it begins counting when the form loads, what am I doing wrong?
Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
[i]unrelated code here[/i]
Private Sub cmdEnter_Click()
Call GoToStep1
Sleep 8000
Call Step2
End Sub
Sleep Method In .Net
I tried to Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
but I got error. I 'm using .Net not VB 6.0
I want to pause my application for some secs.. Usually I used Sleep but Sleep is unknown in .Net. I couldn't find which header file to import. Please help me
Been Loosing Sleep
Was just wondering. I have been working with applications of several kinds till now. I've recently been into an application that pulls data from the server and updates the server of its data. Like a channel, it always gets updated content each time you open the application. However, I've never developed an application that updates each client terminal as soon as the data on the central server is updated.
If I sound like I've slept bad, it is not entirely untrue. I am sitting past midnight and its not uncommon. However, I only want to ask you guys if you can offer me input as to how, say for instance, a stock broker's computer system gets automatically updated the second a scrip's price changes on the bourses. It would be foolhardly to assume the clients had timers which retrieved updates every few milliseconds. We have commonly seen software in the client/server model driven architecture wherein the client sends requests to the server for updates and the updates are exchanged. But this is a case wherein the server probably notifies clients by raising events. How is data exchange handled in this scenario. What could possibly be the underlying technology or set of technologies that make this miracle possible.
Finally, where can I find an overview of Electronic Data Interchange (EDI) for a-holes?
Executing Sleep
hi!
i was wondering if n e of you guys knew how to execute the sleep function, i'm not too familiar w/ it. right now i have a loop that reads in some text from a file & then parses it. after the parsing i want to display the parsed info in some textboxes/labels and aftewards, i want the prog to sleep for a few sec b4 excuting another run. n e ideas? thanks!
|