System.Tests.AppDomainTests.FirstChanceException_Called C# (CSharp) Method

FirstChanceException_Called() private method

private FirstChanceException_Called ( ) : void
return void
        public void FirstChanceException_Called()
        {
            bool flag = false;
            EventHandler<FirstChanceExceptionEventArgs> handler = (sender, e) =>
            {
                Exception ex = (Exception) e.Exception;
                if (ex is FirstChanceTestException)
                {
                    flag = !flag;
                }
            };
            AppDomain.CurrentDomain.FirstChanceException += handler;
            try {
                throw new FirstChanceTestException("testing");
            }
            catch
            {
            }
            AppDomain.CurrentDomain.FirstChanceException -= handler;
            Assert.True(flag, "FirstChanceHandler not called");
        }