* Implemented IDisposable interface for handlers and added virtual method if such needed

This commit is contained in:
2025-08-04 05:22:43 +04:00
parent a794b6ed54
commit e790f31495
2 changed files with 38 additions and 5 deletions
+17 -4
View File
@@ -1,4 +1,5 @@
using Telegrator.Logging;
using Telegrator.Handlers.Components;
using Telegrator.Logging;
using Telegrator.MadiatorCore;
using Telegrator.MadiatorCore.Descriptors;
@@ -79,20 +80,32 @@ namespace Telegrator.Polling
Alligator.LogDebug("Described handler '{0}'", handlerInfo.DisplayString);
HandlerExecuting?.Invoke(handlerInfo);
lastResult = await handlerInfo.HandlerInstance.Execute(handlerInfo);
ExecutingHandlersSemaphore?.Release(1);
using (UpdateHandlerBase instance = handlerInfo.HandlerInstance)
{
lastResult = await instance.Execute(handlerInfo);
ExecutingHandlersSemaphore?.Release(1);
}
if (lastResult.RouteNext)
{
Alligator.LogDebug("Handler requested route continuation");
}
}
catch (NotImplementedException)
{
_ = 0xBAD + 0xC0DE;
}
catch (OperationCanceledException)
{
_ = 0xBAD + 0xC0DE;
break;
}
catch (Exception ex)
{
Alligator.LogError("Failed to process handler!", ex);
}
if (!lastResult.RouteNext)
if (lastResult != null && !lastResult.RouteNext)
break;
}
}