private Task HandlePayloadAsync(object[] parameters) { lock (_payloadLock) { var serverPayload = (JArray)parameters[0]; var payload = _payloadDecompressor.DecompressPayload(serverPayload); OnPayload?.Invoke(payload); return(Task.CompletedTask); } }
private async Task HandlePayloadAsync(JArray parameters) { await _payloadLock.WaitAsync(); try { var serverPayload = parameters; var payload = _payloadDecompressor.DecompressPayload(serverPayload); var context = new UpdateContext(_currentPayloadTime, payload, _initializationData); _currentPayloadTime = context.Time; await(OnUpdateAsync?.Invoke(context) ?? Task.CompletedTask); } finally { _payloadLock.Release(); } }