Option Explicit On 
Option Strict On

Imports System
Imports System.Threading

Module ProfilingSamples
    Public Class Filter
        Shared Sub ExceptionThread()
            Throw New ApplicationException("ExceptionThread")
        End Sub
        Shared Sub TestThread()
            While True
		        Dim t as New Thread(New ThreadStart(AddressOf ExceptionThread))
                Try
		            t.Start()
		            Thread.Sleep(Timeout.Infinite)
                Catch appex As ApplicationException
			        Console.WriteLine("TestThread restartuje: {0}", appex.Message)
                Catch
                    Return
                End Try
		        Thread.Sleep(500)
            End While
        End Sub
        Public Shared Sub Main()
		    Dim t as New Thread(New ThreadStart(AddressOf TestThread))
		    t.Start()
		    Dim input as string = Console.ReadLine()
		    t.Abort()
		    t.Join()
            End Sub
    End Class
End Module