Need help on time out loop after certain time.

Tech-Archive recommends: Fix windows errors by optimizing your registry



hello everyone.

Im trying to time out a loot after a certain time. Probably 5 to 10
minutes.

I have the following function

Private Sub processFileCreation(ByVal source As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim strFilename As String = "c:\web\example.mdb"
Do
Loop While System.IO.File.Exists(strFilename) And
isFileOpen(strFilename)
writeDatabase()

End Sub

This function is being called when it fires the event "created" of a
filewatcher. The file "example.mdb" is being FTPed to the folder. The
loop is to verify if the file is completed written on disk to avoid
exceptions. Is a big file that could take 5 minutes to FTP it that
why I need this loop. Im trying to avoid an infinite loop if some user
has the file open, or if the file is being used by any other software,
so I need to time out the loop.

I've tried to research the web how to use a timer to achieve this but
none of the examples I found could help, plus im kind newb on vb and
vb.net. Lets say this is my first more serious vb.net program :)

Any sugestions?? Any help would be highly appreciated.

Thanks in advance

Joao

.



Relevant Pages

  • Endless Loop
    ... > Private Sub cmdStart_Click ... why the form is left running when the form is told to unload. ... Form.Close will never close a form that holds an endless loop ... Private mbUnload As Boolean ...
    (microsoft.public.vb.general.discussion)
  • Endless Loop
    ... > Private Sub cmdStart_Click ... why the form is left running when the form is told to unload. ... Form.Close will never close a form that holds an endless loop ... Private mbUnload As Boolean ...
    (microsoft.public.vb.database)
  • Re: multiple xml imports from local path
    ... > Dirto loop through all the files in a folder. ... > Private Sub btnImportAllFiles_Click ... > Dim strfile As String ...
    (microsoft.public.access.externaldata)
  • Re: Stop Timer
    ... Private Sub cmdUntilLoop_Click ... Dim intPause As Integer ... MsgBox Timer ... A more elegant way is to have a public variable or control on the form that can be set from outside the loop, and that will be tested in each iteration of the loop to see if it's time to stop. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Search engin
    ... Private Sub find ... Loop While Not c Is Nothing And c.Address firstAddress ... MsgBox "Please note that there are no more entries avaliable" ...
    (microsoft.public.excel.programming)