Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB app 'not responding' in task manager 1

Status
Not open for further replies.

Caradog

Programmer
Jun 28, 2000
73
GB
Solve one problem and along comes another ;)

Fixed my problem with my app always running at 100% cpu usage by using the following...

<SNIP CODE>
'Declarations
Private Declare Sub Sleep Lib &quot;kernel32&quot; _
(ByVal dwMilliseconds As Long)

' Main Sub
Sub Main()
Dim foobar

While foobar <> &quot;OK&quot;
Call myStart
Wend
End Sub
<SNIP CODE>

The myStart sub as a routine to continously scan a directory for a file, which was orignally causing teh CPU max out, so if the directory is empty, instead of looking again, it waits 6000 ms by calling the declration Sleep above.

This works great! No CPU max out, however, after, I think 30 or so seconds of inactivity, task manager reports that the app is not responding, but if I dump a file to be converted into the folder, it pops back to life, then immediate goes back into &quot;not responding&quot; phase until more files are added to the folder and so on.

How do I keep alive my VB app to stop it from not responding??? Jace Hayman
jason.hayman@virgin.net
 
Hi,

Put in a 'DoEvents':
--------------------------------------------------------
Sub Main()
Dim foobar

While foobar <> &quot;OK&quot;
DoEvents
Call myStart
Wend
End Sub
--------------------------------------------------------

Sunaj

 
Sunaj,

Cheers mate! That was spot on! Top Job :) Jace Hayman
jason.hayman@virgin.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top