diff --git a/src/Speckle.Core/Transports/SQLite.cs b/src/Speckle.Core/Transports/SQLite.cs index cf891dd1..fcc2ae25 100644 --- a/src/Speckle.Core/Transports/SQLite.cs +++ b/src/Speckle.Core/Transports/SQLite.cs @@ -276,10 +276,8 @@ public override string ToString() /// Awaits untill write completion (ie, the current queue is fully consumed). /// /// - public async Task WriteComplete() - { + public async Task WriteComplete() => await Utilities.WaitUntil(() => WriteCompletionStatus, 500).ConfigureAwait(false); - } /// /// Returns true if the current write queue is empty and comitted. diff --git a/src/Speckle.Core/Transports/Utilities.cs b/src/Speckle.Core/Transports/Utilities.cs index 92e788e1..42c953a8 100644 --- a/src/Speckle.Core/Transports/Utilities.cs +++ b/src/Speckle.Core/Transports/Utilities.cs @@ -9,21 +9,12 @@ public static class Utilities /// /// /// - /// /// - public static async Task WaitUntil(Func condition, int frequency = 25, int timeout = -1) + public static async Task WaitUntil(Func condition, int frequency = 25) { - var waitTask = Task.Run(async () => + while (!condition()) { - while (!condition()) - { - await Task.Delay(frequency).ConfigureAwait(false); - } - }); - - if (waitTask != await Task.WhenAny(waitTask, Task.Delay(timeout)).ConfigureAwait(false)) - { - throw new SpeckleException("Process timed out", new TimeoutException()); + await Task.Delay(frequency).ConfigureAwait(false); } } } diff --git a/src/Speckle.Transports.MongoDB/MongoDB.cs b/src/Speckle.Transports.MongoDB/MongoDB.cs index 859c2cc2..52a1b7f7 100644 --- a/src/Speckle.Transports.MongoDB/MongoDB.cs +++ b/src/Speckle.Transports.MongoDB/MongoDB.cs @@ -147,18 +147,7 @@ internal void DeleteObject(string hash) /// Awaits until write completion (ie, the current queue is fully consumed). /// /// - public async Task WriteComplete() - { - await Utilities - .WaitUntil( - () => - { - return GetWriteCompletionStatus(); - }, - 500 - ) - .ConfigureAwait(false); - } + public async Task WriteComplete() => await Utilities.WaitUntil(GetWriteCompletionStatus, 500).ConfigureAwait(false); /// /// Returns true if the current write queue is empty and committed.