From 80a76c3d0ac7a8acb0930774a0d7b06f01bc7688 Mon Sep 17 00:00:00 2001 From: Rikitav Date: Sat, 7 Mar 2026 02:44:21 +0400 Subject: [PATCH] Adede global cancellation token creation --- src/Telegrator.Hosting.Web/TypesExtensions.cs | 3 +++ src/Telegrator.Hosting/TypesExtensions.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Telegrator.Hosting.Web/TypesExtensions.cs b/src/Telegrator.Hosting.Web/TypesExtensions.cs index 688a343..e5b95d5 100644 --- a/src/Telegrator.Hosting.Web/TypesExtensions.cs +++ b/src/Telegrator.Hosting.Web/TypesExtensions.cs @@ -63,7 +63,10 @@ namespace Telegrator throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' wasn't registered. This configuration is runtime required!"); } + CancellationTokenSource globallCancell = new CancellationTokenSource(); + options.GlobalCancellationToken = globallCancell.Token; services.AddSingleton(Options.Create(options)); + services.AddKeyedSingleton("cancell", globallCancell); if (handlers != null) { diff --git a/src/Telegrator.Hosting/TypesExtensions.cs b/src/Telegrator.Hosting/TypesExtensions.cs index bc49f23..5525e6d 100644 --- a/src/Telegrator.Hosting/TypesExtensions.cs +++ b/src/Telegrator.Hosting/TypesExtensions.cs @@ -63,7 +63,10 @@ public static class HostBuilderExtensions throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' wasn't registered. This configuration is runtime required!"); } + CancellationTokenSource globallCancell = new CancellationTokenSource(); + options.GlobalCancellationToken = globallCancell.Token; services.AddSingleton(Options.Create(options)); + services.AddKeyedSingleton("cancell", globallCancell); if (handlers != null) {