Link to home
Start Free TrialLog in
Avatar of Bob3975
Bob3975Flag for United States of America

asked on

sleeping problems

I'm using both javascript and vbscript in my asp.  My modules go something like this...
----------------------------------------------------------
<%@ Language = javascript %>
<%
  Pause();
%>

<SCRIPT LANGUAGE="VBScript" RUNAT="SERVER">
Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)
Function Pause()
  Sleep 3000
End Function
</SCRIPT>
---------------------------------------------------

This results in ...
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/iba/test1.asp, line 7, column 16
Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)

If I remove 'Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)' I get...
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'Sleep'

Where did I go wrong and what's the solution?  If the solution includes building a new component I may require help in doing so.
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

This is a very bad idea. You are much better off programming in such a way that you don't need to invoke the sleep method.

FtB
Avatar of Bob3975

ASKER

I'm doing this for testing.  I need to test timing issues by forcing a thread to stop in a critical position without eating up the processor.  I'm assuming that's not bad.  If it is, why?  If not, how can it be done?
For timing, I usually do:

<%
response.write Now()
%>

Do your stuff

<%
response.write Now()
%>

Then you will know how much time has passed.

The problem with Sleep is that you never know for certain how long the event your waiting for is going to take, so it is best to program around that.

FtB
Avatar of Bob3975

ASKER

That doesn't trap the thread in the critical area.  Here's what I'm trying to test, it's more a knowledge builder for myself than anything.

There is a section of code in which I need to update the Application object.  If I set Application.Lock(), what happens to another thread if it tries reading or writing the appication object?  Is try/catch of use?  But most importantly answering those questions and how they are answered will lead to more questions.  It becomes an experience thing.  The best way to learn is through experiencing it.

Therefore it seems to me that I could test and learn if I could trap the thread, and that's why I'd like to force it to sleep.
Avatar of Bob3975

ASKER

I'm using Or http://www.serverobjects.com/products.htm#free, WaitFor 1.0.

No further assistance needed
I hope that works out and good luck!

FtB
Fine with me,

FtB
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Modulo--

Thanks for closing this out.

FtB