Threading and Filewatcher
-
Hi, I want to be able to respond to file changes using filewatcher and during certain changes I would like to spawn a new thread to handle the function. The code below is what I have done during testing. If I rename a single file both fsw_Renamed() and MyTest() Eventlog entries reports the same file name from e.FullPath. However, If I rename say 8 files at the same time the eventlogging in fsw_Renamed() reports each file names but MyTest() eventlogging reports only one file name 8 times. The pvThreads counter works fine in that it will increment increment 8 time. ===================================== Public pvArgs as string Public pvThreads as Integer Public Sub fsw_Renamed(ByVal sender As Object, ByVal e As System.IO.RenamedEventArgs) Handles fsw.Renamed pvArgss = e.FullPath EventLog.WriteEntry(String.Format("Hello --- " & pvArgs), EventLogEntryType. _ Information, 8888) Dim thd As New Thread(AddressOf MyTest) thd.Start() End Sub Sub MyTest() pvThreads = pvThreads + 1 EventLog.WriteEntry(String.Format("MIG ---" & pvThreads & " : " & pvArgs), _ EventLogEntryType.Information, 9999) End Sub ===================================== Could some please assist? Thanks,