L
Lloyd Sheen
I have a problem where I cannot read (all the time) a file when caught by
the FileSystemWatcher. What I have done to get past this is create an array
of events (when I receive one I add it to the list). I then enable a timer
which will attempt to process the first one in the list.
The timer code is never executed. There is a handles clause on the timer
and using the debugger I have watched the code for the FileSystemWatcher
execute. Code below:
Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
Dim poWE As New WatcherEvents
poWE.FileName = e.FullPath
poWE.Type = "Create"
maEvents.Add(poWE)
Timer1.Interval = 500
Timer1.Enabled = True
LogChange(e.FullPath, "Creating request for ", 102)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
LogChange("", "Enter timer routine ", 997)
If maEvents.Count = 0 Then Exit Sub
Dim poWE As WatcherEvents
......
The FileSystemWatcher1_Created executes and the log event happens. The
timer1_tick does not execute. Even when not debugging I should see the
event log at the beginning of the code for that routine but there is
nothing.
Lloyd Sheen
the FileSystemWatcher. What I have done to get past this is create an array
of events (when I receive one I add it to the list). I then enable a timer
which will attempt to process the first one in the list.
The timer code is never executed. There is a handles clause on the timer
and using the debugger I have watched the code for the FileSystemWatcher
execute. Code below:
Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
Dim poWE As New WatcherEvents
poWE.FileName = e.FullPath
poWE.Type = "Create"
maEvents.Add(poWE)
Timer1.Interval = 500
Timer1.Enabled = True
LogChange(e.FullPath, "Creating request for ", 102)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
LogChange("", "Enter timer routine ", 997)
If maEvents.Count = 0 Then Exit Sub
Dim poWE As WatcherEvents
......
The FileSystemWatcher1_Created executes and the log event happens. The
timer1_tick does not execute. Even when not debugging I should see the
event log at the beginning of the code for that routine but there is
nothing.
Lloyd Sheen