Skip to content

Instantly share code, notes, and snippets.

@kshyju
Created August 8, 2022 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kshyju/ad5ea00b24e834127d1c08d274356c66 to your computer and use it in GitHub Desktop.
Save kshyju/ad5ea00b24e834127d1c08d274356c66 to your computer and use it in GitHub Desktop.
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