Skip to content
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

Add ability to wait for Thread to Abort #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MichelZ
Copy link

@MichelZ MichelZ commented Nov 17, 2023

We have the need to wait for a cancelled work item to be aborted, so here's the ability to join to the aborted thread until it exits or there is a timeout

@amibar
Copy link
Owner

amibar commented Nov 17, 2023

Hi,

You shouldn't rely on Thread.Abort() in your code.
It is even not supported in latest .net core versions see https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread.abort

Check the PostExecuteWorkItemCallback delegate to know when a work item completed (successfully or cancelled).
You can use the event SmartThreadPool.OnThreadTermination to know when a thread is terminating.
You can check if a work items is cancelled during its execution using SmartThreadPool.IsWorkItemCanceled

Also note that the code build fails, probably on missing modified file in the commit.

Ami

@MichelZ
Copy link
Author

MichelZ commented Nov 17, 2023

Hi,

You shouldn't rely on Thread.Abort() in your code. It is even not supported in latest .net core versions see https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread.abort

Yes, I know. Unfortunately we don't have a choice here as we're calling thirdparty code with no cancellation support, and it sometimes just hangs.

Also note that the code build fails, probably on missing modified file in the commit.

Right. Fixed

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

Successfully merging this pull request may close these issues.

2 participants