コード例 #1
0
        private async Task MessageLoopImpl()
        {
            try
            {
                await Connect(CancellationToken);

                RechargeHeartbeat();
                while (!CancellationToken.IsCancellationRequested)
                {
                    var response = await Messenger.GetResponseAsync(CancellationToken);

                    RechargeHeartbeat();
                    await HandleResponse(response, CancellationToken);
                }
            }
            finally
            {
                try
                {
                    await Messenger.StopAsync(CancellationToken);
                }
                catch (Exception)
                {
                    // Nothig can do here
                }
            }
        }