|
-
Feb 12th, 2012, 12:47 AM
#1
Thread Starter
Hyperactive Member
Classic ASP Do until FileExists?
I am using a WScript.Shell to call a Java class that creates a file. I need to be able to wait until the file gets created (usually about 15-20 seconds) before I try to open this file in the ASP page.
I tried to use a Do Until fs.FileExists(outFile) loop but that pegs the CPU Cycles out and then the file never gets created. The same goes for any of the normal "Do until" pause couters floating around on the net.
I have also read about WScript.Sleep but that apparently does not work in ASP, only in VBScript files.
I CANNOT use a page refresh to try and check for the file either. The reason is there is a lot of things happening on this page before this point (creating a temp folder, copying files, etc.) and there is response.write after each step to keep the user informed. A refresh would start the process all over.
What I really need is a way to loop asynchronously to allow the background Java to finish creating the file instead of the loop pegging out the server. So something like:
Code:
Do until fs.FileExists(outFile)
DoEvents
loop
Anyone have any ideas?
-
Feb 12th, 2012, 08:49 AM
#2
Re: Classic ASP Do until FileExists?
I'm doing something similar in VB.Net web services with ASP.Net - not fully complete yet but this thread (and a few related one) discuss methods
http://www.vbforums.com/showthread.php?t=671789
-
Feb 13th, 2012, 04:36 PM
#3
Thread Starter
Hyperactive Member
Re: Classic ASP Do until FileExists?
I found a cheater way to get it done, by spawning additional short term "do nothing" type shell processes in the Loop. Really I am just calling Shell("java", , wait), which causes java.exe to return usage information and then exit for each pass of the loop. This allows the file to actually get created without timing out but is not really a good thing to do.
I am now considering packaging this portion of the code into an API and calling it that way, to try and make this more efficient and actually use a real DoEvents.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|