コード例 #1
0
ファイル: MainForm.cs プロジェクト: zhyzhy782/ClownFish.tools
 void _executor_ExecuteError(object sender, ScriptExecuteErrorEventArgs e)
 {
     _syncContext.Post(x => {
         ListViewItem item = listView1.Items[e.Index];
         item.ImageIndex   = ICON_ITEM;                  //ICON_ERROR;
         //item.BackColor = System.Drawing.Color.Pink;
         item.SubItems[1].Text = "-------";
         progressBar.Value     = e.Index + 1;
     }, e);
 }
コード例 #2
0
        private void ProcessException(Exception ex, RequestInfo request, ScriptExecuteErrorEventArgs e2)
        {
            request.Result.Exception = ex;

            WebException wex = ex as WebException;

            if (wex != null)
            {
                RemoteWebException remoteWebException = new RemoteWebException(wex);
                request.Result.Response = remoteWebException.ResponseText;
            }

            if (this.ExecuteError != null)
            {
                this.ExecuteError(this, e2);
            }
        }
コード例 #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();
            }
        }