Skip to content

Remove Thread.Abort in rxThread so that it will support being called from .NET 6 and up. Thread.Abort is deprecated. #1

Description

@johngardner58work

Installed product versions

  • Visual Studio: 2022
  • This extension: 1.1.21

Description

When calling InternalClose there is a call to Thread.Abort(). This call is no longer possible in .net5 and above. Instead you should use the equivalent of a cancellation token to terminate the rxThread. To support legacy frameworks you might need to roll your own. I would do the changes but I don't want to mess with Lesser GPL (that's a whole different topic)

Steps to recreate

private void InternalClose()
{
Win32.NativeMethods.CancelIo(hPort);
if (rxThread != null)
{
try
{
//rxThread.Abort();
rxCancellationTokenSource.Cancel(); //new
//JH 1.3: Improve robustness of Close in case were followed by Open:
rxThread.Join(100);
}
catch (System.Threading.ThreadAbortException)
{ /* NOP */ }
rxThread = null;
}

Current behavior

Thread.Abort is no longer supported in .Net Core. It was never a a robust solution

Expected behavior

Microsoft has moved to the CancelationToken concept. And something like this should be adopted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions