private static async Task ExecuteRequestsAsync( ConcurrentDictionary <string, NetworkRequestCallback> queue, NetworkRequestCallback requestCallback, CancellationTokenSource cts) { if (cts.IsCancellationRequested) { queue.AddOrUpdate( requestCallback.Request.Identifier.ToString(), requestCallback, (s, callback) => requestCallback); return; } NetworkRequest request = requestCallback.Request; WeakReferenceCallback successCallback = requestCallback.SuccessCallback; WeakReferenceCallback errorCallback = requestCallback.ErrorCallback; try { object response = await request.ExecuteAsync(successCallback.Type); successCallback.Invoke(response); } catch (Exception ex) { successCallback.Invoke(Activator.CreateInstance(successCallback.Type)); errorCallback.Invoke(ex); } }