コード例 #1
0
ファイル: Form1.cs プロジェクト: OptoCloud/VRCModsCrawler
        private void Crawler_FormClosing(object sender, FormClosingEventArgs e)
        {
            ThreadStop = true;

            ToggleRunningButton.Text = "Stopping...";
            ToggleRunningButton.Update();
            Crawler.ActiveForm.Enabled       = false;
            Crawler.ActiveForm.UseWaitCursor = true;
            Crawler.ActiveForm.Update();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: OptoCloud/VRCModsCrawler
        private void ToggleRunningButton_Click(object sender, EventArgs e)
        {
            ToggleRunningButton.Enabled = false;

            if (ThreadStop)
            {
                ToggleRunningButton.Text          = "Starting...";
                ToggleRunningButton.UseWaitCursor = true;
                ToggleRunningButton.Update();
                while (ThreadRunning == true)
                {
                    Thread.Sleep(100);
                }

                string orderbyString = "";

                switch (SelectorBox.SelectedIndex)
                {
                case 0:
                    orderbyString = "latest";
                    break;

                case 1:
                    orderbyString = "downloads";
                    break;

                case 2:
                    orderbyString = "hot";
                    break;

                default:
                    ToggleRunningButton.Text = "Start";
                    ToggleRunningButton.Update();
                    return;
                }

                ThreadStop    = false;
                ThreadRunning = true;

                SelectorBox.Enabled = false;
                Task.Run(() =>
                {
                    MainLoop(orderbyString);
                    ThreadRunning = false;
                }).ConfigureAwait(false);
                ToggleRunningButton.Text = "Stop";
            }
            else
            {
                ToggleRunningButton.Text          = "Stopping...";
                ToggleRunningButton.UseWaitCursor = false;
                ToggleRunningButton.Update();
                ThreadStop = true;
                while (ThreadRunning == true)
                {
                    Thread.Sleep(100);
                }
                SelectorBox.Enabled      = true;
                ToggleRunningButton.Text = "Start";
            }

            ToggleRunningButton.Enabled = true;
        }