Esempio n. 1
0
        public override async Task HandleMessage(IDanmakuClient client, IDisconnectedMessage message)
        {
            while (true) // 无限重连
            {
                try
                {
                    await client.ConnectAsync();

                    return;
                }
                catch (OperationCanceledException)
                {
                    break;
                }
                catch (Exception) // 其它异常就丢掉, 你也可以自己魔改
                {
                    try
                    {
                        await Task.Delay(1000, message.Token); // 等1秒
                    }
                    catch (OperationCanceledException)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
 protected override Task ExecuteAsync(CancellationToken stoppingToken)
 {
     return(_client.ConnectAsync(stoppingToken));
 }