コード例 #1
0
ファイル: MainForm.cs プロジェクト: zhyzhy782/ClownFish.tools
 void _executor_BeforeExecute(object sender, ScriptExecuteEventArgs e)
 {
     _syncContext.Post(x => {
         ListViewItem item = listView1.Items[e.Index];
         item.ImageIndex   = ICON_CURRENT;
         labMessage.Text   = "正在请求:" + e.Option.Url;
     }, e);
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: zhyzhy782/ClownFish.tools
 void _executor_AfterExecute(object sender, ScriptExecuteEventArgs e)
 {
     _syncContext.Post(x => {
         ListViewItem item     = listView1.Items[e.Index];
         item.ImageIndex       = ICON_ITEM;              //ICON_OK;
         item.SubItems[1].Text = e.Request.Result.Time.ToString();
         progressBar.Value     = e.Index + 1;
     }, e);
 }
コード例 #3
0
        private void ExecuteReqest(RequestInfo request, HttpOption option, int index)
        {
            request.Result = new ExecuteResult();

            ScriptExecuteEventArgs e1 = new ScriptExecuteEventArgs {
                Index   = index,
                Option  = option,
                Request = request
            };

            if (this.BeforeExecute != null)
            {
                this.BeforeExecute(this, e1);
            }

            Stopwatch watch = Stopwatch.StartNew();

            try {
                string result = option.Send <string>();
                watch.Stop();

                request.Result.Response = result;
                request.Result.Time     = watch.Elapsed;

                if (this.AfterExecute != null)
                {
                    this.AfterExecute(this, e1);
                }
            }
            catch (Exception ex) {
                watch.Stop();
                _errorCount++;

                ScriptExecuteErrorEventArgs e2 = new ScriptExecuteErrorEventArgs {
                    Index     = index,
                    Option    = option,
                    Request   = request,
                    Exception = ex
                };
                ProcessException(ex, request, e2);
            }
            finally {
                request.Result.RequestText = option.ToRawText();
            }
        }