Dim scanAutoResetEvent As New AutoResetEvent(True) Private Sub ScanDirectory(dir As String) Try scanAutoResetEvent.WaitOne() If _config.LogLevel.ToLower = "high" Then LogMessages("Scanning: " + dir, Reflection.MethodBase.GetCurrentMethod.Name) End If Dim _di As DirectoryInfo = New DirectoryInfo(dir) Using finished As New CountdownEvent(1) For Each _xmlFile In _di.EnumerateFiles("*.xml", SearchOption.AllDirectories) Dim _ri As ReportInfo = New ReportInfo() _ri.XMLINfo = _xmlFile _ri.Pad = _xmlFile.Directory.Parent.ToString If _config.Threading Then ThreadPool.QueueUserWorkItem(New WaitCallback(Function(x) Try LoadToDepcon(_ri) Finally finished.Signal() End Try End Function)) Else LoadToDepcon(_ri) End If 'End If Next finished.Signal() finished.Wait() End Using Catch ex As Exception LogMessages(ex.Message, Reflection.MethodBase.GetCurrentMethod.Name, 300, "E", False, True) Finally scanAutoResetEvent.Set() End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)