Solved

sleeping problems

Posted on 2004-08-28
10
405 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now