1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-07-22 09:25:26 +00:00

Added support for sending query without expecting a response

This commit is contained in:
Jkorf 2025-05-19 16:06:45 +02:00
parent f1342b5ff2
commit 2cf10668dd

View File

@ -79,6 +79,11 @@ namespace CryptoExchange.Net.Sockets
/// </summary> /// </summary>
public int Weight { get; } public int Weight { get; }
/// <summary>
/// Whether the query should wait for a response or not
/// </summary>
public bool ExpectsResponse { get; set; } = true;
/// <summary> /// <summary>
/// Get the type the message should be deserialized to /// Get the type the message should be deserialized to
/// </summary> /// </summary>
@ -116,10 +121,19 @@ namespace CryptoExchange.Net.Sockets
/// </summary> /// </summary>
public void IsSend(TimeSpan timeout) public void IsSend(TimeSpan timeout)
{ {
// Start timeout countdown
RequestTimestamp = DateTime.UtcNow; RequestTimestamp = DateTime.UtcNow;
_cts = new CancellationTokenSource(timeout); if (ExpectsResponse)
_cts.Token.Register(Timeout, false); {
// Start timeout countdown
_cts = new CancellationTokenSource(timeout);
_cts.Token.Register(Timeout, false);
}
else
{
Completed = true;
Result = CallResult.SuccessResult;
_event.Set();
}
} }
/// <summary> /// <summary>