Beispiel #1
0
        private async void ButtonGetChats_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxLiveChatId.Text))
            {
                MessageBox.Show("Live Chat ID okunamadı!", "", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return;
            }

            timerViewerCount.Start();
            timerChatCount.Start();
            await Task.Delay(200);

            _tokenSource           = new CancellationTokenSource();
            _liveChats             = new LinkedList <LiveChatModel>();
            buttonGetChats.Enabled = false;
            pbWorking.Visible      = true;
            ChatCount = 0;

            try
            {
                //TODO: Yoğunluk her sn istek geliyor. Progress bunlardan birini işlemeden diğer istek gelirse hata alacak veya kaydemeyecek. Çözüm bulunmalı
                Progress <ReportChatModel> progress1 = new Progress <ReportChatModel>();
                progress1.ProgressChanged += ReportProgress;

                Progress <ReportChatModel> progress2 = new Progress <ReportChatModel>();
                progress2.ProgressChanged += ReportProgress2;

                await _youtubeApi.GetLiveChatsAsync(textBoxLiveChatId.Text, textBoxVideoId.Text, _tokenSource.Token, progress1);

                //await Task.Delay(5000);
                //_youtubeApi.GetLiveChatsAsync(textBoxLiveChatId.Text, textBoxVideoId.Text, _tokenSource.Token, progress2);
            }
            catch (OperationCanceledException ox)
            {
                MessageBox.Show($"Servis durduruldu.\r\"{ox.Message}", "", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }