In my multithreaded applications, on occassion the error Que Is Empty occurs when trying to clear the que. Is there any way to prevent this from happening or catch it without causing the program to lock up? Below is the code that throws the exception.
Private Sub Callback(ByVal o As Object) If tasks.Count > 0 Then Dim Task As Action SyncLock (Lock) Task = tasks.Dequeue End SyncLock Task.BeginInvoke(AddressOf Callback, Nothing) Else Threading.Interlocked.Decrement(RunningThread) End If End Sub
Any help would be great apprecied.