private async Task runPollingLoop() { while (isStarted) { BotsLongPollHistoryResponse response; try { response = BotsLongPollHistoryResponse.FromJson(await api.CallLongPollAsync(connection.Server, (VkParameters)connection)); } catch (LongPollOutdateException exception) { connection.Ts = exception.Ts; continue; } catch (Exception exception) when(exception is LongPollKeyExpiredException || exception is LongPollInfoLostException) { await connection.Create(); continue; } catch (Exception) { throw; } connection.Ts = response.Ts; foreach (var update in response.Updates) { await Handler?.Handle(update); } } }