• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

C# - Looking for some code to wait for a for an external process

I'm developing an app that requests data from an external Oracle DB via a WAN connection. The Oracle DB is SLOW to return the data. Depending on the data being requested, the response time varies from 3 minutes to 20 minutes. Here's an algorithm I'm planning on developing. I need suggestions with Step 3

Step 1 - Delete the local copy of the previous Oracle export file (tab-delimited).
Step 2 - Send request to Oracle server for new file (using BAT/CMD file combo).
Step 3 - Wait for 60 seconds.
Step 4 - Check for the presence of the new export file.
Step 5 - Is the file there? Advance to Step 6. If not, return to step 3.
Step 6 - Import the file.
0
jdana
Asked:
jdana
3 Solutions
 
Michael FowlerSolutions ConsultantCommented:
The following will cause the application to wait for 60 seconds

System.Threading.Thread.Sleep(60000);

Michael
0
 
Naman GoelSoftware engineer 1Commented:
Yes, Thread.Sleep will stop the executing thread for given amount of time. However if you want remain responsive (UI doesn't freeze) you might consider timers.
0
 
CodeCruiserCommented:
>Step 4 - Check for the presence of the new export file.

Given that you are waiting for a file to be created, instead of using timers or making threads sleep, you can use the FileSystemWatcher object to monitor the folder and when the file arrives, your code will be triggered automatically so you can import the file


http://www.codeproject.com/Articles/3192/Watching-Folder-Activity-in-VB-NET

http://www.blackwasp.co.uk/FileSystemWatcher.aspx
0
 
jdanaAuthor Commented:
Thanks to all three of you for some excellent responses.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now