Skip to content

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