Skip to content

FCS: enable cancelation of FSI-sessions by host. #14546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

goswinr
Copy link
Contributor

@goswinr goswinr commented Jan 5, 2023

Fix for #14489
On net7 (and net48) this new member allows cancellation of FSI threads in a hosted context such as WPF or WinForms. All fsi evaluations on net7 run under System.Runtime.ControlledExecution.Run().
Doing the cancellation myself by wrapping it into System.Runtime.ControlledExecution.Run()again does not work. It would fail with Compiler Error:input.fsx (1,1)-(1,1) interactive error internal error: The thread is already executing the ControlledExecution.Run method.
So hosted evaluations can only be cancelled if this or a similar new member is added.

@goswinr goswinr requested a review from a team as a code owner January 5, 2023 15:00
@vzarytovskii
Copy link
Member

@KevinRansom could you please review this?

@goswinr
Copy link
Contributor Author

goswinr commented Jan 8, 2023

@KevinRansom all checks are green now. I hope you can accept this PR. Let me know if I should update some other documentation about FSI too.

Copy link
Contributor

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goswinr,
Interrupt is the API for this. TryAbort uses ThreadAbort, which has opportunities to corrupt coreclr internal state and the bcl is no longer hardened against thread abort. The API was added for FSharp because we had no way of interrupting executing script code.

You should use Interrupt for the scenario you have in mind. That will cause the thread to be aborted relatively cleanly, and we can clean up our interrupt handlers. If you have a scenario that this doesn't work for then we can figure out how to fix Interrupt.

@KevinRansom
Copy link
Contributor

KevinRansom commented Jan 14, 2023

@Goswin Thank you for ths contribution, you should use the Interrupt API to cause executing scripts to halt. I am closing this PR. If there are issues with Interrupt please document them and we will try to address them.

Kevin

@goswinr goswinr deleted the abortFsi branch August 31, 2023 12:15
@goswinr
Copy link
Contributor Author

goswinr commented Dec 14, 2024

this was solved by #15184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants