コード例 #1
0
            private void bw_DoWork(object sender, DoWorkEventArgs e)
            {
                Thread.Sleep(1000);
                ProgressInfo progressInfo = new ProgressInfo();
                int          progress, elapsed;
                DateTime     time;

                while (!bw.CancellationPending)
                {
                    time = DateTime.Now;
                    try
                    {
                        progressInfo.ParseResponse(sendSpace.SendRequest(HttpMethod.POST, url));
                        if (progressInfo.Status != "fail" && !string.IsNullOrEmpty(progressInfo.Meter))
                        {
                            if (int.TryParse(progressInfo.Meter, out progress))
                            {
                                //sendSpace.OnProgressChanged(0, 0);
                            }
                        }
                    }
                    catch
                    {
                    }
                    elapsed = (int)(DateTime.Now - time).TotalMilliseconds;
                    if (elapsed < interval)
                    {
                        Thread.Sleep(interval - elapsed);
                    }
                }
            }
コード例 #2
0
ファイル: SendSpace.cs プロジェクト: ywscr/ShareX
            private void DoWork(CancellationToken ct)
            {
                Thread.Sleep(1000);
                ProgressInfo progressInfo = new ProgressInfo();
                DateTime     time;

                while (!ct.IsCancellationRequested)
                {
                    time = DateTime.Now;
                    try
                    {
                        string response = sendSpace.SendRequest(HttpMethod.POST, url);

                        progressInfo.ParseResponse(response);

                        if (progressInfo.Status != "fail" && !string.IsNullOrEmpty(progressInfo.Meter))
                        {
                            if (int.TryParse(progressInfo.Meter, out int progress))
                            {
                                //sendSpace.OnProgressChanged(0, 0);
                            }
                        }
                    }
                    catch
                    {
                    }
                    int elapsed = (int)(DateTime.Now - time).TotalMilliseconds;
                    if (elapsed < interval)
                    {
                        Thread.Sleep(interval - elapsed);
                    }
                }
            }