fisdelom
fisdelom

Reputation: 39

How can I delay execution of a part of script in Classic ASP?

I've a classic ASP page which call a en external webservice. this is how the actual process works:

'[Part0 : Call the external webservice]
wsResponse = setConfirmation(...)


' [PART1: external webservice is responding]    
if not wsResponse is Nothing then
 '....Process the response from the webservice according to wsResponse
  code =wsResponse.getCode
  if code = 'C' then
     'We confirm the transaction and call a storedprocedure in SqlServer
  else
    'if code is different from C, we assume, the transaction status is 'not confirmed' or 'cancelled'

 '[PART2: no answer from external webservice] 
Else 
  'so wsReponse is nothing..We don't get any answer from the external webservice
    'transaction is not confirmed
   'the transaction status is set to 'not confirmed' in database

So what I want to do is that in PART2 (when no answer is get from external webservice), wait 30 seconds before send 'not confirmed' status in database . So I will like to do PART0 again ie: Call again the external webservice at least 10 times and see if it responding or not. A kind of recursive process. So I was thinking of 2 way of doing this:

  1. In PART2, put ASP to sleep for 30s and to PART0 again (Call the webservice) and if still no response, write in DB, transaction not confirmed, but if response, then do PART1.

  2. In PART2, Call repeat PART0 at least 10 times, if after 10 trials, there is no response, then write in DB, transaction is not confirmed.

So my question is: is there a better way to do this or which or 1 or 2 will be better? and also, for 1, how can we put ASP to sleep like in dotnet or PHP?

Thanks for your answers.

Regards

Upvotes: 1

Views: 5042

Answers (2)

Here is a simple subroutine that will delay for as many seconds as you need

Sub MyDelay(NumberOfSeconds)
Dim DateTimeResume
  DateTimeResume= DateAdd("s", NumberOfSeconds, Now())
  Do Until (Now() > DateTimeResume)
  Loop
End Sub

Just call this subroutine in Part 2

Call MyDelay(30)

Upvotes: 5

PC-Gram
PC-Gram

Reputation: 79

I don't know any way to put ASP to sleep. Especially when you are on a hosted web. So what I would do is this: I would have a service like Pingdom.com to request an ASP page every say 10 seconds. The requested ASP page will then attend to any pending transactions (logged in a tabel).

Upvotes: 0

Related Questions