internal static void HandleApiCall <T, B>(SteamAPICall_t call, CancellationToken token, Action <B, bool> handler) { if (token.IsCancellationRequested) { return; } CallResultHolder <B> .Set(call, (result, bIOFailure) => handler(result, bIOFailure)); }
internal static Task <T> HandleApiCall <T, B>(SteamAPICall_t call, CancellationToken token, Action <TaskCompletionSource <T>, B, bool> handler) { return(TaskHelper.FromAction <T>(tsc => { if (token.IsCancellationRequested) { tsc.TrySetCanceled(); return; } CallResultHolder <B> .Set(call, (result, bIOFailure) => handler(tsc, result, bIOFailure)); token.Register(() => tsc.TrySetCanceled()); })); }
internal static void CancelApiCall <T>() { CallResultHolder <T> .Cancel(); }