With .NET Core 6, When an unhandled exception occurs in the application, particularly a load error, I want to dump it into a text file and open the default text editor.
The problem is that the text editor gets killed as soon as the app exits!
Process.WaitForExit() doesn't work because I didn't start the app directly, but rather launched the text file.
So far, the best I could do is to wait 10 seconds before exiting the app... how can I do better? Solution needs to work cross-platform.
if (logPath != null)
{
    // Dump error to log file and open default text editor.
    var log = logPath();
    System.IO.File.WriteAllText(log, ex.ToString());
    var notepad = new Process
    {
        StartInfo = new ProcessStartInfo(log)
        {
            UseShellExecute = true
        }
    };
    notepad.Start();
    Thread.Sleep(TimeSpan.FromSeconds(10));
}
EDIT: I'm using Jetbrains Rider in Linux. If I run the application directly outside the IDE, then it stays open!
 
    