#if NETFRAMEWORK using System.Threading.Tasks; #endif namespace ReC.Client { /// /// Provides synchronous wrappers for Task-based operations. /// [System.Obsolete("Synchronous blocking helpers (Task.Sync) are no longer recommended. These methods can cause deadlocks or unexpected behavior. Rewrite calling code to use async/await (e.g. async Task tests). This helper class will be removed in a future release.", false)] public static class TaskSyncExtensions { /// /// Blocks until the task completes and propagates any exception. /// /// The task to wait for. [System.Obsolete("Use async/await instead of synchronous blocking. This method can cause deadlocks.", false)] public static void Sync(this Task task) => task.ConfigureAwait(false).GetAwaiter().GetResult(); /// /// Blocks until the task completes and returns its result, propagating any exception. /// /// The type of the task result. /// The task to wait for. /// The result of the completed task. [System.Obsolete("Use async/await instead of synchronous blocking. This method can cause deadlocks.", false)] public static TResult Sync(this Task task) => task.ConfigureAwait(false).GetAwaiter().GetResult(); } }