From 2cf10668ddbe95d9f92311d7678d1b60768733e6 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Mon, 19 May 2025 16:06:45 +0200 Subject: [PATCH] Added support for sending query without expecting a response --- CryptoExchange.Net/Sockets/Query.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/CryptoExchange.Net/Sockets/Query.cs b/CryptoExchange.Net/Sockets/Query.cs index c024fb3..9357a33 100644 --- a/CryptoExchange.Net/Sockets/Query.cs +++ b/CryptoExchange.Net/Sockets/Query.cs @@ -79,6 +79,11 @@ namespace CryptoExchange.Net.Sockets /// public int Weight { get; } + /// + /// Whether the query should wait for a response or not + /// + public bool ExpectsResponse { get; set; } = true; + /// /// Get the type the message should be deserialized to /// @@ -116,10 +121,19 @@ namespace CryptoExchange.Net.Sockets /// public void IsSend(TimeSpan timeout) { - // Start timeout countdown RequestTimestamp = DateTime.UtcNow; - _cts = new CancellationTokenSource(timeout); - _cts.Token.Register(Timeout, false); + if (ExpectsResponse) + { + // Start timeout countdown + _cts = new CancellationTokenSource(timeout); + _cts.Token.Register(Timeout, false); + } + else + { + Completed = true; + Result = CallResult.SuccessResult; + _event.Set(); + } } ///