Need a simple behind the scenes counter to use as a pause for an asp page

Posted on 2011-05-02
Last Modified: 2012-05-11
Is there a simple way to pause an ASP page? I'm thinking maybe having a simple VB6 dll  i could call from an ASP page so the processor doesn't get pinned.

i'm currently using
Sub Sleep(intSeconds)
    dteStart = Time()
    dteEnd = DateAdd("s", intSeconds, dteStart)
    While dteEnd > Time()
End Sub

Open in new window

This works fine seeing as the page runs locally on a kiosk, the only problem is that the loader image i'm using won't paint... processors go to 50% each and the page basically comes back to life after the delay has expired.

can someone provide a simple bit-o-code for this vb timer i'm thinking of or give a better solution
Question by:cyberdyne_dev
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Have you considered using the sleep API function?
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    ' If this is an int like '5', then multiply by 1000 because Sleep() expects milliseconds to sleep. e.g.
    Sleep(intSeconds * 1000)

    Open in new window

    LVL 74

    Accepted Solution


    So you know, the Sleep() API function causes the thread calling it to sleep, allowing other threads to continue processing. It is designed to allow the processor to do other work while some thread is sleeping.
    LVL 27

    Assisted Solution

    >>having a simple VB6 dll <<  
    It is not necessary to invent a bicycle. Such dll already exists:
    <script language="VBScript">
          set WshShell = WScript.CreateObject("WScript.Shell")
          WScript.Sleep 1000 'sleep 1 sec
    <script language="JScript">
          var WshShell = WScript.CreateObject("WScript.Shell");
    LVL 27

    Expert Comment

    If WScript.Sleep won't work with ASP, you can use;
    <script language="VBScript">
    Sub Delay( seconds )
        Dim wshShell
        Set wshShell = CreateObject( "WScript.Shell" )
        wshShell.Run "ping -n " & ( seconds + 1 ) & "", 0, True
        Set wshShell = Nothing
    End Sub
    LVL 3

    Author Comment

    where and how would i use the API function? example please

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    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

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    760 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

    9 Experts available now in Live!

    Get 1:1 Help Now