Results 1 to 6 of 6

Thread: [RESOLVED] Suppressing workflow exceptions from being logged

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Resolved [RESOLVED] Suppressing workflow exceptions from being logged

    Hello everyone. I am dealing with a very multithreaded environment at the moment, and as you may expect, this involves the complicated subject of properly aborting a thread.
    Now I know that calling .Abort() on it is not the way to go, so that is not what I do. Instead I have a variable declared that states whether a thread should continue or not.
    When aborting, it's a simple process of changing this state and calling Join() on the Thread.

    Example, this is in an Image frame storing class that also handles the animation:
    Code:
        Private Sub UpdateAnimation()
            Try
                While Not disposedValue
                    Dim now As Date = Date.Now
                    If now.Subtract(Me.m_lastFrameChange).TotalMilliseconds >= Me.m_frameDelays(Me.m_frameIndex) Then
                        Me.m_lastFrameChange = now
                        If Me.m_frameIndex = Me.m_frameTotal - 1 Then
                            Me.CurrentFrame = 0
                        Else
                            Me.CurrentFrame += 1
                        End If
                    End If
                    Threading.Thread.Sleep(50)
                End While
            Catch ex As System.Threading.ThreadInterruptedException
            End Try
        End Sub
    To abort:
    Code:
    Me.disposedValue = True
    ' ... some other disposing logic ...
    Me.m_animateThread.Interrupt()
    Me.m_animateThread.Join()
    Now what is the issue? The Interrupt. In my IDE it spams a pointless message despite it being handled in the Try-Catch:
    Code:
    A first chance exception of type 'System.Threading.ThreadInterruptedException' occurred in mscorlib.dll
    A first chance exception of type 'System.Threading.ThreadInterruptedException' occurred in mscorlib.dll
    A first chance exception of type 'System.Threading.ThreadInterruptedException' occurred in mscorlib.dll
    A first chance exception of type 'System.Threading.ThreadInterruptedException' occurred in mscorlib.dll
    Is there any way to COMPLETELY hide this exception from the debugger?
    It heavily spams my IDE and masks any legitimate runtime exceptions or debugging information to be shown.

    I've run into the same issue with invoking on controls where the control is disposed...it forced me to do complicated event handling and SyncLocking to abort whatever thread from invoking things.
    In this case, however, the interrupt is needed to avoid wasting 50ms of a thread waiting period. The message forces me not to do it though...

    An alternative way of interrupting a Wait that does not cause an exception logged is fine, too.
    Last edited by bergerkiller; Oct 27th, 2013 at 10:31 AM. Reason: Moved try-catch

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width