IClosable

Interface that allows you to create a component with a method that closes it and frees used resources.

Description

The IClosable interface allows you to create a component with a method that closes it and frees used resources.

Instance methods

CloseAsync

Closes a component and frees used resources.

Task CloseAsync(IContext context)

  • context: IContext - (optional) a context to trace execution through a call chain.

Examples

class MyConnector: IClosable 
{
    private object _client = null;
    ... // The _client can be lazy created
    public void Close(IContext context)
    {
        if (this._client != null)
        {   
            this._client.Close();
            this._client = null;
        }
    }
}

See also