From 0022b3e7e669b4f2165d9398b5886bb708150841 Mon Sep 17 00:00:00 2001 From: shaan1337 Date: Tue, 2 Jun 2020 16:30:14 +0400 Subject: [PATCH] Support infinite timeouts --- src/EventStore.Client.Streams/DeadLine.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/EventStore.Client.Streams/DeadLine.cs b/src/EventStore.Client.Streams/DeadLine.cs index e38b3e67c..5561c4290 100644 --- a/src/EventStore.Client.Streams/DeadLine.cs +++ b/src/EventStore.Client.Streams/DeadLine.cs @@ -1,10 +1,14 @@ using System; +using System.Threading; #nullable enable namespace EventStore.Client { internal static class DeadLine { - public static DateTime? After(TimeSpan? timeoutAfter) => - timeoutAfter.HasValue ? DateTime.UtcNow.Add(timeoutAfter.Value) : (DateTime?)null; + public static DateTime? After(TimeSpan? timeoutAfter){ + if(!timeoutAfter.HasValue) return null; + if(timeoutAfter.Value == TimeSpan.MaxValue || timeoutAfter.Value == Timeout.InfiniteTimeSpan) return DateTime.MaxValue; + return DateTime.UtcNow.Add(timeoutAfter.Value); + } public static TimeSpan? None = null; }