{"id":1824,"date":"2015-01-26T17:50:59","date_gmt":"2015-01-26T09:50:59","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=1824"},"modified":"2015-01-26T17:51:20","modified_gmt":"2015-01-26T09:51:20","slug":"%e5%9f%ba%e4%ba%8e-qworker-%e7%9a%84%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%bc%96%e7%a8%8b-%e7%8a%b6%e6%80%81%e8%b7%9f%e8%b8%aa","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=1824","title":{"rendered":"\u57fa\u4e8e QWorker \u7684\u591a\u7ebf\u7a0b\u7f16\u7a0b \u2013 \u72b6\u6001\u8ddf\u8e2a"},"content":{"rendered":"<p>\u5f53\u6211\u4eec\u5c06\u4e00\u4e2a\u4f5c\u4e1a\u7684\u6267\u884c\u59d4\u6258\u7ed9 Workers \u8fd9\u4e2a\u5305\u5de5\u5934\u4ee5\u540e\uff0c\u90a3\u4e48\u8fd9\u4e2a\u4f5c\u4e1a\u5b9e\u9645\u4e0a\u5c31\u5904\u4e8e\u4e09\u79cd\u72b6\u6001\u4e4b\u4e00\uff1a<\/p>\n<ul>\n<li>\u6392\u961f\u4e2d\uff1a\u4f5c\u4e1a\u5728\u961f\u5217\u4e2d\u7b49\u5f85\u88ab\u8c03\u5ea6\u6267\u884c<\/li>\n<li>\u8fd0\u884c\u4e2d\uff1a\u4f5c\u4e1a\u6b63\u5728\u6267\u884c<\/li>\n<li>\u5df2\u5b8c\u6210\uff1a\u4f5c\u4e1a\u5df2\u7ecf\u6267\u884c\u5b8c\uff0c\u6b64\u65f6\u4f5c\u4e1a\u53ca\u76f8\u5173\u8fde\u7684\u6570\u636e\u90fd\u5df2\u81ea\u52a8\u88ab\u91ca\u653e<\/li>\n<\/ul>\n<p>\u7531\u4e8e\u5df2\u7ecf\u5b8c\u6210\u7684\u4f5c\u4e1a\u4f1a\u88ab\u91ca\u653e\u6389\uff0c\u6240\u4ee5\uff0c\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u80fd\u5f97\u5230\u7684\u72b6\u6001\u53ea\u6709\u6392\u961f\u4e2d\u548c\u8fd0\u884c\u4e2d\u4e24\u79cd\uff0c\u7b2c\u4e09\u79cd\u7531\u4e8e\u4f5c\u4e1a\u5df2\u7ecf\u4e0d\u5b58\u5728\uff0c\u6211\u4eec\u5c31\u65e0\u6cd5\u68c0\u6d4b\u5230\u5176\u72b6\u6001\u3002<\/p>\n<p>QWorker \u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570\u6765\u8ddf\u8e2a\u4f5c\u4e1a\u7684\u72b6\u6001\uff1aPeekJobState \u548c EnumJobStates\uff0c\u524d\u8005\u9488\u5bf9\u7684\u662f\u5355\u4e2a\u5177\u4f53\u7684\u4f5c\u4e1a\uff0c\u540e\u8005\u9488\u5bf9\u7684\u662f\u5168\u90e8\u4f5c\u4e1a\u3002\u5728\u5177\u4f53\u4e86\u89e3\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u770b\u4e00\u4e0b\u6211\u4eec\u80fd\u5f97\u5230\u7684\u4f5c\u4e1a\u72b6\u6001\u4fe1\u606f\u5b9a\u4e49\uff1a<\/p>\n<p>\u3010Delphi\u3011<\/p>\n<pre class=\"lang:delphi decode:true\">\/\/\/ &lt;summary&gt;\u4f5c\u4e1a\u72b6\u6001&lt;\/summary&gt;\r\n  TQJobState = record\r\n    Handle: IntPtr; \/\/ \u4f5c\u4e1a\u5bf9\u8c61\u53e5\u67c4\r\n    Proc: TQJobMethod; \/\/ \u4f5c\u4e1a\u8fc7\u7a0b\r\n    Flags: Integer; \/\/ \u6807\u5fd7\u4f4d\r\n    IsRunning: Boolean; \/\/ \u662f\u5426\u5728\u8fd0\u884c\u4e2d\uff0c\u5982\u679c\u4e3aFalse\uff0c\u5219\u4f5c\u4e1a\u5904\u4e8e\u961f\u5217\u4e2d\r\n    Runs: Integer; \/\/ \u5df2\u7ecf\u8fd0\u884c\u7684\u6b21\u6570\r\n    EscapedTime: Int64; \/\/ \u5df2\u7ecf\u6267\u884c\u65f6\u95f4\r\n    PushTime: Int64; \/\/ \u5165\u961f\u65f6\u95f4\r\n    PopTime: Int64; \/\/ \u51fa\u961f\u65f6\u95f4\r\n    AvgTime: Int64; \/\/ \u5e73\u5747\u65f6\u95f4\r\n    TotalTime: Int64; \/\/ \u603b\u6267\u884c\u65f6\u95f4\r\n    MaxTime: Int64; \/\/ \u6700\u5927\u6267\u884c\u65f6\u95f4\r\n    MinTime: Int64; \/\/ \u6700\u5c0f\u6267\u884c\u65f6\u95f4\r\n    NextTime: Int64; \/\/ \u91cd\u590d\u4f5c\u4e1a\u7684\u4e0b\u6b21\u6267\u884c\u65f6\u95f4\r\n  end;<\/pre>\n<p>\u3010C++ Builder\u3011<\/p>\n<pre class=\"lang:delphi decode:true\">struct DECLSPEC_DRECORD TQJobState\r\n{\r\npublic:\r\n\tNativeInt Handle;\r\n\tTQJobMethod Proc;\r\n\tint Flags;\r\n\tbool IsRunning;\r\n\tint Runs;\r\n\t__int64 EscapedTime;\r\n\t__int64 PushTime;\r\n\t__int64 PopTime;\r\n\t__int64 AvgTime;\r\n\t__int64 TotalTime;\r\n\t__int64 MaxTime;\r\n\t__int64 MinTime;\r\n\t__int64 NextTime;\r\n};<\/pre>\n<p>\u5728\u8c03\u7528 PeekJobState \u65f6\uff0c\u5982\u679c\u627e\u5230\u4f5c\u4e1a\uff0c\u5219 Handle \u4e0e\u4f20\u5165\u7684\u4f5c\u4e1a\u53e5\u67c4\u4e00\u81f4\uff0cProc \u6307\u5411\u4f5c\u4e1a\u5bf9\u5e94\u7684\u8fc7\u7a0b\u53e5\u67c4\uff0cFlags \u662f\u4f5c\u4e1a\u7684\u6807\u5fd7\u4f4d\uff0c\u4fdd\u5b58\u7684\u662f JOB_XXX \u6807\u5fd7\u4f4d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f4d\u4e0e\u7684\u65b9\u5f0f\u6765\u68c0\u67e5\u5404\u4e2a\u6807\u5fd7\u4f4d\u662f\u5426\u8bbe\u7f6e\uff0c\u5177\u4f53\u6807\u5fd7\u4f4d\u5b9a\u4e49\u53c2\u8003\u4e0b\u8868\uff1a<\/p>\n<blockquote><p>JOB_RUN_ONCE \uff1a \u4f5c\u4e1a\u53ea\u8fd0\u884c\u4e00\u6b21<br \/>\nJOB_IN_MAINTHREAD \uff1a \u4f5c\u4e1a\u53ea\u80fd\u5728\u4e3b\u7ebf\u7a0b\u4e2d\u8fd0\u884c<br \/>\nJOB_MAX_WORKERS \uff1a \u5c3d\u53ef\u80fd\u591a\u7684\u5f00\u542f\u53ef\u80fd\u7684\u5de5\u4f5c\u8005\u7ebf\u7a0b\u6765\u5904\u7406\u4f5c\u4e1a\uff0c\u6682\u4e0d\u652f\u6301<br \/>\nJOB_LONGTIME \uff1a \u4f5c\u4e1a\u9700\u8981\u5f88\u957f\u7684\u65f6\u95f4\u624d\u80fd\u5b8c\u6210\uff0c\u4ee5\u4fbf\u8c03\u5ea6\u7a0b\u5e8f\u51cf\u5c11\u5b83\u5bf9\u5176\u5b83\u4f5c\u4e1a\u7684\u5f71\u54cd<br \/>\nJOB_SIGNAL_WAKEUP \uff1a \u4f5c\u4e1a\u6839\u636e\u4fe1\u53f7\u9700\u8981\u5524\u9192<br \/>\nJOB_TERMINATED \uff1a \u4f5c\u4e1a\u4e0d\u9700\u8981\u7ee7\u7eed\u8fdb\u884c\uff0c\u53ef\u4ee5\u7ed3\u675f\u4e86<br \/>\nJOB_GROUPED \uff1a \u5f53\u524d\u4f5c\u4e1a\u662f\u4f5c\u4e1a\u7ec4\u7684\u4e00\u5458<br \/>\nJOB_ANONPROC \uff1a \u5f53\u524d\u4f5c\u4e1a\u8fc7\u7a0b\u662f\u533f\u540d\u51fd\u6570<br \/>\nJOB_FREE_OBJECT :\u00a0Data\u5173\u8054\u7684\u662fObject\uff0c\u4f5c\u4e1a\u5b8c\u6210\u6216\u6e05\u7406\u65f6\u91ca\u653e<br \/>\nJOB_FREE_RECORD :\u00a0Data\u5173\u8054\u7684\u662fRecord\uff0c\u4f5c\u4e1a\u5b8c\u6210\u6216\u6e05\u7406\u65f6\u91ca\u653e<br \/>\nJOB_FREE_INTERFACE :\u00a0Data\u5173\u8054\u7684\u662fInterface\uff0c\u4f5c\u4e1a\u5b8c\u6210\u65f6\u8c03\u7528_Release<br \/>\nJOB_FREE_CUSTOM1 :\u00a0Data\u5173\u8054\u7684\u6210\u5458\u7531\u7528\u6237\u6307\u5b9a\u7684\u65b9\u5f0f1\u91ca\u653e<br \/>\nJOB_FREE_CUSTOM2 :\u00a0Data\u5173\u8054\u7684\u6210\u5458\u7531\u7528\u6237\u6307\u5b9a\u7684\u65b9\u5f0f2\u91ca\u653e<br \/>\nJOB_FREE_CUSTOM3 :\u00a0Data\u5173\u8054\u7684\u6210\u5458\u7531\u7528\u6237\u6307\u5b9a\u7684\u65b9\u5f0f3\u91ca\u653e<br \/>\nJOB_FREE_CUSTOM4 :\u00a0Data\u5173\u8054\u7684\u6210\u5458\u7531\u7528\u6237\u6307\u5b9a\u7684\u65b9\u5f0f4\u91ca\u653e<br \/>\nJOB_FREE_CUSTOM5 :\u00a0Data\u5173\u8054\u7684\u6210\u5458\u7531\u7528\u6237\u6307\u5b9a\u7684\u65b9\u5f0f5\u91ca\u653e<br \/>\nJOB_FREE_CUSTOM6 :\u00a0Data\u5173\u8054\u7684\u6210\u5458\u7531\u7528\u6237\u6307\u5b9a\u7684\u65b9\u5f0f6\u91ca\u653e<br \/>\nJOB_DATA_OWNER :\u00a0\u4f5c\u4e1a\u662fData\u6210\u5458\u7684\u6240\u6709\u8005<\/p><\/blockquote>\n<p>\u597d\u4e86\uff0c\u73b0\u5728\u6211\u4eec\u6765\u770b PeekJobState \u7684\u5b9a\u4e49\uff1a<\/p>\n<p>\u3010Delphi\u3011<\/p>\n<pre class=\"lang:delphi decode:true\">    \/\/\/ &lt;summary&gt;\u83b7\u53d6\u6307\u5b9a\u4f5c\u4e1a\u7684\u72b6\u6001&lt;\/summary&gt;\r\n    \/\/\/ &lt;param name=\"AHandle\"&gt;\u4f5c\u4e1a\u5bf9\u8c61\u53e5\u67c4&lt;\/param&gt;\r\n    \/\/\/ &lt;param name=\"AResult\"&gt;\u4f5c\u4e1a\u5bf9\u8c61\u72b6\u6001&lt;\/param&gt;\r\n    \/\/\/ &lt;returns&gt;\u5982\u679c\u6307\u5b9a\u7684\u4f5c\u4e1a\u5b58\u5728\uff0c\u5219\u8fd4\u56deTrue\uff0c\u5426\u5219\uff0c\u8fd4\u56deFalse&lt;\/returns&gt;\r\n    \/\/\/ &lt;remarks&gt;\r\n    \/\/\/ 1.\u5bf9\u4e8e\u53ea\u6267\u884c\u4e00\u6b21\u7684\u4f5c\u4e1a\uff0c\u5728\u6267\u884c\u5b8c\u540e\u4e0d\u590d\u5b58\u5728\uff0c\u6240\u4ee5\u4e5f\u4f1a\u8fd4\u56defalse\r\n    \/\/\/ 2.\u5728FMX\u5e73\u53f0\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u533f\u540d\u51fd\u6570\u4f5c\u4e1a\u8fc7\u7a0b\uff0c\u5fc5\u9700\u8c03\u7528 ClearJobState \u51fd\u6570\u6765\u6267\u884c\u6e05\u7406\u8fc7\u7a0b\uff0c\u4ee5\u907f\u514d\u5185\u5b58\u6cc4\u9732\u3002\r\n    \/\/\/ &lt;\/remarks&gt;\r\n    function PeekJobState(AHandle: IntPtr; var AResult: TQJobState): Boolean;<\/pre>\n<p>\u3010C++ Builder\u3011<\/p>\n<pre class=\"lang:delphi decode:true \">bool __fastcall PeekJobState(NativeInt AHandle, TQJobState &amp;AResult);<\/pre>\n<p>\u8bf7\u6ce8\u610f\u5176\u4e2d\u7684\u6ce8\u91ca\u4e2d\u7684 Remark \u90e8\u5206\u8bf4\u660e\uff0cPeekJobState \u7684\u8fd4\u56de\u503c\u4e3a\u5b89\u5168\u8d77\u89c1\uff0c\u5efa\u8bae\u4f7f\u7528 ClearJobState \u6765\u91ca\u653e\u8fd4\u56de\u7684\u7ed3\u679c\uff0c\u4ee5\u4f7f\u533f\u540d\u51fd\u6570\u7684\u5f15\u7528\u8ba1\u6570\u5728\u79fb\u52a8\u5e73\u53f0\u5de5\u4f5c\u6b63\u5e38\u3002<\/p>\n<p>\u6211\u4eec\u770b\u4e0b ClearJobState \u7684\u5b9e\u73b0\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">procedure ClearJobState(var AState: TQJobState);\r\nbegin\r\nif IsFMXApp then\r\n  begin\r\n  if (AState.Flags and JOB_ANONPROC) &lt;&gt; 0 then\r\n    begin\r\n    IUnknown(AState.Proc.ProcA)._Release;\r\n    end;\r\n  AState.Proc.Code := nil;\r\n  AState.Proc.Data := nil;\r\n  end;\r\nend;<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u53ea\u662f\u5728\u00a0FMX\u00a0\u5e73\u53f0\u5b83\u8d77\u4f5c\u4e1a\uff0cVCL \u4e2d\uff0c\u7531\u4e8e ProcA \u5b9a\u4e49\u4e3a TQJobProcA \u6240\u4ee5\u4f1a\u81ea\u52a8\u91ca\u653e\uff08FMX \u5e73\u53f0 ProcA \u7684\u5b9a\u4e49\u4e3a Pointer\uff0c\u5b9a\u4e49\u4e3a TQJobProcA \u65e0\u6cd5\u7f16\u8bd1\uff09\u3002<\/p>\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u662f PeekJobState \u7684\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">var\r\n  AState: TQJobState;\r\n  S: String;\r\n  ATime: Int64;\r\n  ALoc: TQSymbolLocation;\r\nbegin\r\nATime := GetTimeStamp;\r\nif Workers.PeekJobState(FSignalWaitHandle, AState) then\r\n  begin\r\n  S := '\u4f5c\u4e1a ';\r\n  if (AState.Flags and JOB_ANONPROC) = 0 then\r\n    begin\r\n    if LocateSymbol(AState.Proc.Code, ALoc) then\r\n      S := S + ' - ' + ALoc.FunctionName\r\n    else\r\n      S := S + TObject(AState.Proc.Data).MethodName(AState.Proc.Code);\r\n    end\r\n  else\r\n    S := S + ' - \u533f\u540d\u51fd\u6570';\r\n  if AState.IsRunning then\r\n    S := S + ' \u8fd0\u884c\u4e2d:'#13#10\r\n  else\r\n    S := S + ' \u8ba1\u5212\u4e2d:'#13#10;\r\n  case AState.Handle and $03 of\r\n    0:\r\n      begin\r\n      S := S + ' \u7b80\u5355\u4f5c\u4e1a'#13#10;\r\n      ShowMessage(S);\r\n      Exit;\r\n      end;\r\n    1:\r\n      S := S + ' \u91cd\u590d\u4f5c\u4e1a(\u8ddd\u4e0b\u6b21\u6267\u884c\u65f6\u95f4: ' + FormatFloat('0.#',\r\n        (AState.NextTime - ATime) \/ 10) + 'ms)'#13#10;\r\n    2:\r\n      S := S + ' \u4fe1\u53f7\u4f5c\u4e1a'#13#10;\r\n  end;\r\n  S := S + ' \u5df2\u8fd0\u884c:' + IntToStr(AState.Runs) + ' \u6b21'#13#10 + ' \u4efb\u52a1\u63d0\u4ea4\u65f6\u95f4:' +\r\n    RollupTime((ATime - AState.PushTime) div 10000) + ' \u524d'#13#10;\r\n  if AState.PopTime &lt;&gt; 0 then\r\n    S := S + ' \u672b\u6b21\u6267\u884c\u65f6\u95f4:' + RollupTime((ATime - AState.PopTime) div 10000) +\r\n      ' \u524d' + #13#10;\r\n  S := S + ' \u5e73\u5747\u6bcf\u6b21\u7528\u65f6:' + FormatFloat('0.#', AState.AvgTime \/ 10) + 'ms'#13#10\r\n    + ' \u603b\u8ba1\u7528\u65f6:' + FormatFloat('0.#', AState.TotalTime \/ 10) + 'ms'#13#10 +\r\n    ' \u6700\u5927\u7528\u65f6:' + FormatFloat('0.#', AState.MaxTime \/ 10) + 'ms'#13#10 +\r\n    ' \u6700\u5c0f\u7528\u65f6:' + FormatFloat('0.#', AState.MinTime \/ 10) + 'ms'#13#10;\r\n  S := S + ' \u6807\u5fd7\u4f4d:';\r\n  if (AState.Flags and JOB_RUN_ONCE) &lt;&gt; 0 then\r\n    S := S + '\u5355\u6b21,';\r\n  if (AState.Flags and JOB_IN_MAINTHREAD) &lt;&gt; 0 then\r\n    S := S + '\u4e3b\u7ebf\u7a0b,';\r\n  if (AState.Flags and JOB_GROUPED) &lt;&gt; 0 then\r\n    S := S + '\u5df2\u5206\u7ec4,';\r\n  if S[Length(S)] = ',' then\r\n    SetLength(S, Length(S) - 1);\r\n  ShowMessage(S);\r\n  ClearJobState(AState);\r\n  end\r\nelse\r\n  ShowMessage('\u672a\u627e\u5230\u8bf7\u6c42\u7684\u53e5\u67c4\u5bf9\u5e94\u7684\u4f5c\u4e1a\uff0c\u4f5c\u4e1a\u53ef\u80fd\u5df2\u7ecf\u5b8c\u6210\u3002');\r\nend;<\/pre>\n<p>\u5f53\u7136\uff0c\u4e0a\u9762\u7684\u4f8b\u5b50\u7531\u4e8e\u7528\u5230\u4e86 QMapSymbols \u5355\u5143\u7684\u51fd\u6570\uff0c\u6240\u4ee5\u53ea\u80fd\u5728 Delphi \u7684 Windows \u4e0b\u7a0b\u5e8f\u4e2d\u8fd0\u884c\u3002<\/p>\n<p>\u4e0e PeekJobState \u4e0d\u540c\uff0cEnumJobStates \u662f\u8fd4\u56de\u4e00\u4e2a\u52a8\u6001\u6570\u7ec4\u6765\u5305\u542b\u6240\u6709\u7684\u4f5c\u4e1a\u7684\u72b6\u6001\uff0c\u58f0\u660e\u5982\u4e0b\uff1a<\/p>\n<p>\u3010Delphi\u3011<\/p>\n<pre class=\"lang:delphi decode:true \">    \/\/\/ &lt;summary&gt;\u679a\u4e3e\u6240\u6709\u7684\u4f5c\u4e1a\u72b6\u6001&lt;\/summary&gt;\r\n    \/\/\/ &lt;returns&gt;\u8fd4\u56de\u4f5c\u4e1a\u72b6\u6001\u5217\u8868&lt;\/summary&gt;\r\n    \/\/\/ &lt;remarks&gt;\u5728FMX\u5e73\u53f0\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u533f\u540d\u51fd\u6570\u4f5c\u4e1a\u8fc7\u7a0b\uff0c\u5fc5\u9700\u8c03\u7528 ClearJobStates \u51fd\u6570\u6765\u6267\u884c\u6e05\u7406\u8fc7\u7a0b&lt;\/remarks&gt;\r\n    function EnumJobStates: TQJobStateArray;<\/pre>\n<p>\u3010C++ Builder\u3011<\/p>\n<pre class=\"lang:c++ decode:true \">TQJobStateArray __fastcall EnumJobStates(void);<\/pre>\n<p>\u8fd9\u4e2a\u548c PeekJobState \u5f88\u7c7b\u4f3c\uff0c\u5c31\u4e0d\u518d\u8d58\u8ff0\uff0c\u76f4\u63a5\u4e0a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">var\r\n  AStates: TQJobStateArray;\r\n  I: Integer;\r\n  ATime: Int64;\r\n  ALoc: TQSymbolLocation;\r\n  ABuilder:TQStringCatHelperW;\r\nbegin\r\nATime := GetTimeStamp;\r\nAStates := Workers.EnumJobStates;\r\nABuilder:=TQStringCatHelperW.Create;\r\nABuilder.Cat('\u5171\u53d1\u73b0 ').Cat(Length(AStates)).Cat(' \u9879\u4f5c\u4e1a'#13#10);\r\nfor I := 0 to High(AStates) do\r\n  begin\r\n  if ABuilder.Position&gt;1000 then\r\n    begin\r\n    ABuilder.Cat('...(\u540e\u7eed\u7701\u7565)');\r\n    Break;\r\n    end;\r\n  ABuilder.Cat('\u4f5c\u4e1a #').Cat(I + 1);\r\n  if (AStates[I].Flags and JOB_ANONPROC) = 0 then\r\n    begin\r\n    if LocateSymbol(AStates[I].Proc.Code, ALoc) then\r\n      ABuilder.Cat(' - ').cat(ALoc.FunctionName)\r\n    else\r\n      ABuilder.Cat(TObject(AStates[I].Proc.Data).MethodName(AStates[I].Proc.Code));\r\n    end\r\n  else\r\n    ABuilder.Cat(' - \u533f\u540d\u51fd\u6570');\r\n  if AStates[I].IsRunning then\r\n    ABuilder.Cat(' \u8fd0\u884c\u4e2d:'#13#10)\r\n  else\r\n    ABuilder.Cat(' \u8ba1\u5212\u4e2d:'#13#10);\r\n  case AStates[I].Handle and $03 of\r\n    0:\r\n      begin\r\n      ABuilder.Cat(' \u7b80\u5355\u4f5c\u4e1a'#13#10);\r\n      Continue;\r\n      end;\r\n    1:\r\n      ABuilder.Cat(' \u91cd\u590d\u4f5c\u4e1a(\u8ddd\u4e0b\u6b21\u6267\u884c\u65f6\u95f4: ' + FormatFloat('0.#',\r\n        (AStates[I].NextTime - ATime) \/ 10) + 'ms)'#13#10);\r\n    2:\r\n      ABuilder.Cat(' \u4fe1\u53f7\u4f5c\u4e1a'#13#10);\r\n  end;\r\n  ABuilder.Cat(' \u5df2\u8fd0\u884c:').Cat(AStates[I].Runs).Cat(' \u6b21'#13#10).Cat(' \u4efb\u52a1\u63d0\u4ea4\u65f6\u95f4: ').Cat(\r\n    RollupTime((ATime - AStates[I].PushTime) div 10000)).Cat(' \u524d'#13#10);\r\n  if AStates[I].PopTime &lt;&gt; 0 then\r\n    ABuilder.Cat(' \u672b\u6b21\u6267\u884c\u65f6\u95f4: ').Cat(RollupTime((ATime - AStates[I].PopTime) div 10000)).Cat(\r\n      ' \u524d'#13#10);\r\n  ABuilder.Cat(' \u5e73\u5747\u6bcf\u6b21\u7528\u65f6:').Cat(FormatFloat('0.#', AStates[I].AvgTime \/ 10)).Cat('ms'#13#10)\r\n    .Cat(' \u603b\u8ba1\u7528\u65f6:').Cat(FormatFloat('0.#', AStates[I].TotalTime \/ 10)).Cat('ms'#13#10).Cat(\r\n    ' \u6700\u5927\u7528\u65f6:').Cat(FormatFloat('0.#', AStates[I].MaxTime \/ 10)).Cat('ms'#13#10).Cat(\r\n    ' \u6700\u5c0f\u7528\u65f6:').Cat(FormatFloat('0.#', AStates[I].MinTime \/ 10)).Cat('ms'#13#10);\r\n  ABuilder.Cat(' \u6807\u5fd7\u4f4d:');\r\n  if (AStates[I].Flags and JOB_RUN_ONCE) &lt;&gt; 0 then\r\n    ABuilder.Cat('\u5355\u6b21,');\r\n  if (AStates[I].Flags and JOB_IN_MAINTHREAD) &lt;&gt; 0 then\r\n    ABuilder.Cat('\u4e3b\u7ebf\u7a0b,');\r\n  if (AStates[I].Flags and JOB_GROUPED) &lt;&gt; 0 then\r\n    ABuilder.Cat('\u5df2\u5206\u7ec4,');\r\n  ABuilder.Cat(SLineBreak);\r\n  end;\r\nClearJobStates(AStates);\r\nShowMessage(ABuilder.Value);\r\nFreeObject(ABuilder);\r\nend;<\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u9650\u5236\u4e86\u4e0b\u6700\u591a\u663e\u793a\u524d1000\u4e2a\u5b57\u8282\u7684\u5185\u5bb9\uff0c\u5426\u5219\u592a\u957f\u4e86\uff0c\u7528 ShowMessage \u663e\u793a\u4f1a\u9020\u6210\u5047\u6b7b\u7684\u73b0\u8c61\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u6211\u4eec\u5c06\u4e00\u4e2a\u4f5c\u4e1a\u7684\u6267\u884c\u59d4\u6258\u7ed9 Worke [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,9,6],"tags":[57],"class_list":["post-1824","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-qdac","category-qworker","tag-57"],"views":3483,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1824"}],"version-history":[{"count":2,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1824\/revisions"}],"predecessor-version":[{"id":1826,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1824\/revisions\/1826"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}