Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sleeping problems

Posted on 2004-08-28
10
Medium Priority
?
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

598 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