Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AccountManger] Wrong Implement of Dispose pattern #67

Closed
myroot opened this issue Jan 22, 2018 · 1 comment · Fixed by #611
Closed

[AccountManger] Wrong Implement of Dispose pattern #67

myroot opened this issue Jan 22, 2018 · 1 comment · Fixed by #611
Assignees

Comments

@myroot
Copy link
Contributor

myroot commented Jan 22, 2018

protected virtual void Dispose(bool disposing)
{
if (!disposing)
{
_handle.Dispose();
}
}

When disposing was true,

  • Unmanaged and managed resource should be released.

When disposing was false,

  • Only Unmanaged resource should be released.

And SafeHandle is managed resource

https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/dispose-pattern

@myroot
Copy link
Contributor Author

myroot commented Dec 13, 2018

Here is correct answer

    protected virtual void Dispose(bool disposing)
    {
        if (disposing)
        {
            _handle.Dispose();
        }
    }

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 a pull request may close this issue.

4 participants