Esempio n. 1
0
        public void StartSubThd()
        {
            try
            {
                string     guid   = Guid.NewGuid().ToString();
                SendRecord record = new SendRecord()
                {
                    SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"), GUID = guid
                };

                VerifyResult result = PostImage2(guid);

                record.CompleteTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff");
                record.RespString   = result != null ? result.AnnexData : "";
                times.Add(record);
                Interlocked.Increment(ref completeCnt);
                if (result == null)
                {
                    Interlocked.Increment(ref otherErrCnt);
                }
                else
                {
                    string respString = result.AnnexData.ToLower();
                    if (respString.Contains("targets"))
                    {
                        Interlocked.Increment(ref successCnt);
                    }
                    else if (respString.Contains("time is out"))
                    {
                        Interlocked.Increment(ref timeoutCnt);
                    }
                    else if (respString.Contains("image is invalid"))
                    {
                        Interlocked.Increment(ref errorCnt);
                    }
                    else if (respString.Contains("error"))
                    {
                        Interlocked.Increment(ref otherErrCnt);
                    }
                    else
                    {
                        Interlocked.Increment(ref unKnow);
                        Logger.AddLog(this.GetType(), "StartSubThd", respString);
                    }
                }

                if ((Interval < 100 && completeCnt % 10 == 0) || Interval >= 100 || completeCnt == total)
                {
                    this.Invoke(new MethodInvoker(delegate()
                    {
                        lbSuccessCnt.Text = successCnt.ToString();
                        lbTimeout.Text    = timeoutCnt.ToString();
                        lbErrorCnt.Text   = errorCnt.ToString();
                        lbOtherErr.Text   = otherErrCnt.ToString();
                        lbundnow.Text     = unKnow.ToString();
                        if (completeCnt == total)
                        {
                            lbHdTimes.Text  = "处理完成,共耗时:" + (DateTime.Now - dt1).TotalSeconds.ToString() + " 秒";
                            button1.Enabled = true;
                        }
                    }));
                }
            }
            catch (Exception exp)
            {
                Logger.AddLog(this.GetType(), "StartSubThd", "", exp);
            }
        }