Skip to content

CanOpenNodeExtensions Class

Asynchronous disposal for ICanOpenNode.

public static class CanOpenNodeExtensions

Inheritance Object → CanOpenNodeExtensions

Remarks

ICanOpenNode itself stays IDisposable: adding IAsyncDisposable to a published interface would break everyone who implements it. The nodes this library creates implement it, and DisposeAsync(this ICanOpenNode) reaches it without a cast. It cannot be used with await using on an ICanOpenNode (that needs the interface); cast to IAsyncDisposable for that.

Methods

CanOpenNodeExtensions.DisposeAsync(this ICanOpenNode) Method

Disposes node without holding a thread while it waits for the node's reader and event pump to finish, which IDisposable.Dispose does for up to two seconds. Either call may be made from a subscriber of the node (an event, ApplicationReset, BackgroundExceptionOccurred): the task that subscriber runs on is then not waited for. A second call while the first is running returns when the disposal has finished, except from a subscriber of the node, which cannot wait for a disposal that is waiting for it and returns at once. A node that is not one of this library's is disposed on the thread pool.

public static System.Threading.Tasks.ValueTask DisposeAsync(this CanKit.Pro.CANopen.ICanOpenNode node);

Parameters

node ICanOpenNode

The node to dispose.

Returns

ValueTask