|
-
Feb 15th, 2008, 03:20 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2005] How to time out a procedure
Good day all
I am trying to check if a file exists for a path, but how can i put a timer on this so that if it is not working then it will time out instead of taking a long long time to send the error message?
Cheers
Code:
Sub GetInfo()
If System.IO.File.Exists(DataSourcePath) = True Then
'Do something
Else
Msgbox "Error: file cannot be fould"
frm.Label1.text = "ERROR"
End if
End Sub
If you find my thread helpful, please remember to rate me 
-
Feb 15th, 2008, 03:26 AM
#2
Re: [2005] How to time out a procedure
How can File.Exists take a long time? Either the file exists or it doesn't. The result should be instantaneous. I don't think that method can even throw an exception.
-
Feb 15th, 2008, 03:36 AM
#3
Thread Starter
Frenzied Member
Re: [2005] How to time out a procedure
it takes a long time as sometimes people do not have the network drive mapped or have access to it
If you find my thread helpful, please remember to rate me 
-
Feb 15th, 2008, 03:45 AM
#4
Re: [2005] How to time out a procedure
I just tried File.Exists on a disconnected network drive and it took 0.0000673 seconds. Anyway, I'll take your word for it that there are circumstances where it doesn't return immediately. You can't do anything about that though. It's a blocking method so there's nothing you can do to force it to return. The only possibility would to execute it in a background thread and forcibly terminate that thread if it didn't complete within a certain time. That seems pretty extreme for something so simple though. I think a better option would be to make sure users have access to the specific resources first.
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
|