evgenles / TelegramVkBot

Telegram vk bot writed on .net core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible unsafe behavior

vladkolodka opened this issue · comments

Dispose(false);

protected virtual void Dispose(bool disposing)

Microsoft says:

DO NOT access any finalizable objects in the finalizer code path, because there is significant risk that they will have already been finalized.

Bool parameter in Dispose(bool) should be used to prevent Dispose calls on objects that may be already finalized.

See more info in docs.

Fixed disposing

protected virtual void Dispose(bool disposing)
{
_telegram.StopReceiving();
_vkPool.Stop();
if (disposing)
{
if (_vk != null)
_vk.Dispose();
if (_vkNet != null)
_vkNet.Dispose();
if (_httpClient != null)
_httpClient.Dispose();
}
}