I am debugging a program containing Environment.Exit(0);
in LINQPad
.
When this line Environment.Exit(0);
hits, LINQPad
exits.
Visual Studio
, obviously just the process terminates). Simple example:
void Main()
{
Environment.Exit(0);
}
This happens because LINQPad executes queries in the same process as itself, isolating queries via application domain rather than process.
This has changed in the latest beta: LINQPad now runs each query in its own process. This is in preparation for the upcoming integrated debugger (it's impossible debug your own process). A pleasant side-effect is that calling Environment.Exit (or throwing a StackOverflowException) no longer crashes the host process.
LINQPad hosts executed code in an asynchronous thread (to not lock the UI) of its own process, so when you run instructions such as Environment.Exit, hosting process (hence Linqpad itself) is affected too.
You can easily check this by running a long program which makes some calculations : there is no new process in task manager, and linqpad process CPU usage is raising according to computations.
You can tweak a few things in Advanced Options related to application domain for example, but AFAIK there is no way to avoid this behavior since Linqpad entirely relies on this way to execute code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With