Muokkaa

Jaa


AnonymousPipeServerStream.Dispose behavior for HandleInheritability.Inheritable

To avoid resource leaks, your code should call the AnonymousPipeServerStream.DisposeLocalCopyOfClientHandle() method after passing the client handle to the child process. The behavior of AnonymousPipeServerStream.Dispose has been improved to lower the chance of similar leaks for users who don't call DisposeLocalCopyOfClientHandle().

Previous behavior

Previously, the client handle owned by the AnonymousPipeServerStream instance wasn't disposed by AnonymousPipeServerStream.Dispose unless the handle wasn't exposed at all.

New behavior

Starting in .NET 8, the client handle owned by a server that was created for out-of-proc communication is disposed by AnonymousPipeServerStream.Dispose if it's not exposed by using the AnonymousPipeServerStream.ClientSafePipeHandle property. (You create a server for out-of-proc communication by passing HandleInheritability.Inheritable to the AnonymousPipeServerStream(PipeDirection, HandleInheritability) constructor.)

Version introduced

.NET 8 Preview 1

Type of breaking change

This change is a behavioral change.

Reason for change

This change was introduced to avoid a common resource leak.

If a server was created for out-of-proc communication, don't reuse the client handle that's exposed as a string via the GetClientHandleAsString() method after the server instance has been disposed.

Affected APIs