Solved

sleeping problems

Posted on 2004-08-28
10
407 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:Bob3975
  • 5
  • 3
10 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11921835
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
0
 

Author Comment

by:Bob3975
ID: 11921891
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?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11921910
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
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:Bob3975
ID: 11921944
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.
0
 

Author Comment

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

No further assistance needed
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11923274
I hope that works out and good luck!

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11931067
Fine with me,

FtB
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11931241
PAQ-ing the question and refunding 250  points

Thanks  fritz_the_blank

modulo

Community Support Moderator
Experts Exchange
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11931298
Modulo--

Thanks for closing this out.

FtB
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question