Created
August 8, 2022 18:55
-
-
Save kshyju/ad5ea00b24e834127d1c08d274356c66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleAppNetFr481 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
AppDomain currentDomain = AppDomain.CurrentDomain; | |
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyAppDomainErrHandler); | |
void MyAppDomainErrHandler(object sender, UnhandledExceptionEventArgs args1) | |
{ | |
Exception e = (Exception)args1.ExceptionObject; | |
Console.WriteLine("MyAppDomainErrHandler caught : " + e.Message); | |
Console.WriteLine("MyAppDomainErrHandler Runtime terminating: {0}", args1.IsTerminating); | |
} | |
for (var i = 0; i<100;i++) | |
{ | |
Print(i); | |
} | |
RecurseAndCauseStackOverflow(); | |
} | |
private static void Print(int i) | |
{ | |
Console.WriteLine($"Hello {i}"); | |
} | |
private static void RecurseAndCauseStackOverflow(string input = "") | |
{ | |
var st = DateTime.Now; | |
RecurseAndCauseStackOverflow(st.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment