-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
There are a range of execution environments for .NET code that have historically utilised non-cooperative cancellation. These environments have the following characteristics
-
in-process compilation and execution
-
execute arbitrary .NET code entered interactively by the user
-
use arbitrary .NET libraries
-
most user code runs solely on one specific known thread
-
these are developer scenarios (not production scenarios) - in the sense that the developer is issuing the abort while coding/executing and it is not happening as a routine part of production execution
-
reliability of the cancellation mechanism must be "good" but need not be "perfect" - occasional weirdness requiring process restart is tolerated by the developer.
Examples are
-
the F# REPL (
dotnet fsi) -
the C# REPL (
dotnet csi) -
.NET Interactive notebook kernels
and likely many others.
On .NET Framework these have previously relied on Thread.Abort() to support some cancellation scenarios (user enters code, preses run and suddenly decides that wasn't a good idea). However Thread.Abort() has been removed from .NET Core, see #11369
At the moment it's impossible to have an "Interrupt" button in any .NET execution environment executing arbitrary user code, ever. For example, .NET Interactive Jupyter notebooks can't support the Jupyter "Interrupt" button to stop user code execution, or a future .NET teaching environment can't ever have an "Interrupt" button. And REPLs can't support Ctrl-C, one of the most basic functions of a REPL.
These scenarios matter for the long term future of .NET.
This continues the discussion about production scenarios here: #11369 (comment)
@jkotas said
We still have the "good enough" thread abort functionality available for debuggers via debugging APIs. If the other debugger-like environments cannot act as real debuggers, I would not be opposed to exploring ways how to make the thread abort available to them.
@dsyme said:
In theory it might be possible to rearchitect the F# REPL to use a supervised process but it would be a large amount of work. And that work would likely be needed again for .NET Interactive and C# REPL. It's very different to what we are doing today for F# Interactive etc....
Finally @dsyme suggested this:
If it were possible to put on the agenda a
System.Runtime.Helpers.UnsafeThreadAbortOnlyForUseByInteractiveExecutionEnvironmentsActingAsTheirOwnSupervisor()that would be grand....