Exemple #1
0
        async Task SubscribeToEvent(CancellationToken cancellation)
        {
            try
            {
                using var call = Client.Subscribe(Subscription);
                var responseReaderTask = Task.Run(async() =>
                {
                    while (await call.ResponseStream.MoveNext())
                    {
                        if (call.ResponseStream.Current.Type == Subscription.Type)
                        {
                            OnEvent?.Invoke(this, new PostEnvetArgs(call.ResponseStream.Current));
                        }
                    }
                }, cancellation);

                await responseReaderTask;
            }
            catch (OperationCanceledException) { }
            catch { throw; }
        }