{"id":5304,"date":"2021-03-25T15:30:55","date_gmt":"2021-03-25T07:30:55","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=5304"},"modified":"2021-03-25T15:30:56","modified_gmt":"2021-03-25T07:30:56","slug":"%e3%80%90%e6%95%99%e7%a8%8b%e3%80%91%e5%af%b9-tevent-%e7%9a%84%e4%b8%80%e5%a4%84%e5%a2%9e%e5%bc%ba","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=5304","title":{"rendered":"\u3010\u6559\u7a0b\u3011\u5bf9 TEvent \u7684\u4e00\u5904\u589e\u5f3a"},"content":{"rendered":"\n<p>\u5bf9\u4e8e TEvent \u6765\u8bf4\uff0c\u5982\u679c\u662f\u8c03\u7528 WaitFor \u7b49\u5f85\u8d85\u65f6\u65f6\uff0c\u5982\u679c\u7a0b\u5e8f\u9000\u51fa\u65f6\uff0c\u4e8b\u4ef6\u4ecd\u5728\u7b49\u5f85\u72b6\u6001\uff0c\u5c31\u9700\u8981\u7b49\u5f85\u8d85\u65f6\u624d\u80fd\u9000\u51fa\uff0c\u9020\u6210\u7a0b\u5e8f\u9000\u51fa\u65f6\u7b49\u5f85\u5f88\u957f\u65f6\u95f4\u3002\u8981\u6539\u8fdb\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u9700\u8981\u65b0\u7248\u7684 QWorker\uff0c\u5b83\u5b9e\u73b0\u4e86\u4e00\u4e2a TAbortableEvent \u7684\u8bb0\u5f55\u7c7b\u578b\uff0c\u7136\u540e\u652f\u6301\u53d6\u6d88\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>TAbortableEvent \u7684\u589e\u5f3a\u5728\u4e8e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u63d0\u4f9b\u4e86 AbortWait \u65b9\u6cd5\u6765\u4e2d\u6b62\u4e00\u4e2a\u4e8b\u4ef6\u7684\u7b49\u5f85\uff0cWaitFor \u6b64\u65f6\u8fd4\u56de wrAbandoned\u3002<\/li><li>\u8c03\u7528 AddTerminateProc \u6ce8\u518c\u56de\u8c03\u51fd\u6570\uff0c\u5728\u7528\u6237\u8c03\u7528 Application.Terminate \u7ed3\u675f\u7a0b\u5e8f\u65f6\uff0c\u4f1a\u4e2d\u65ad\u6240\u6709\u5173\u8054\u4e8b\u4ef6\u7684\u7b49\u5f85\uff0c\u5e76\u8fd4\u56de wrAbandoned\u3002<\/li><li>\u7531\u4e8e\u4f7f\u7528\u4e86\u6808\u4e0a\u53d8\u91cf\u5b9a\u4e49\u7684\u65b9\u5f0f\uff0c\u6240\u4ee5\u907f\u514d\u4e86\u5806 \u4e0a\u5185\u5b58\u5206\u914d\u9020\u6210\u7684\u6548\u7387\u95ee\u9898\u3002<\/li><\/ul>\n\n\n\n<p>TAbortableEvent  \u7684\u539f\u578b\u5b9a\u4e49\u53c2\u8003\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  PAbortableEvent = ^TAbortableEvent;\n\n  TAbortableEvent = record\n  private\n    class var First, Last: PAbortableEvent;\n  private\n    Prior, Next: PAbortableEvent;\n    Event: TEvent;\n    Aborted: Boolean;\n    procedure InsertWait(AEvent: TEvent);\n    procedure RemoveWait;\n  public\n    function WaitFor(AEvent: TEvent; const ATimeout: Cardinal): TWaitResult;\n    procedure AbortWait;\n    class procedure AbortAll; static;\n  end;<\/code><\/pre>\n\n\n\n<p>\u516c\u5f00\u4e09\u4e2a\u51fd\u6570\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>WaitFor \u66ff\u4ee3 TEvent.WaitFor  \u6765\u6267\u884c\u5b9e\u9645\u7684\u7b49\u5f85<\/li><li>AbortWait \u4e2d\u6b62\u5f53\u524d\u7b49\u5f85\u5e76\u4f7f\u7b49\u5f85\u7684\u7ebf\u7a0b\u8fd4\u56de wrAbandoned<\/li><li>AbortAll \u4e2d\u6b62\u6240\u6709\u7b49\u5f85\u7684\u4e8b\u4ef6\u5e76\u4f7f\u6240\u6709\u7b49\u5f85\u7684\u7ebf\u7a0b\u8fd4\u56de wrAbandoned<\/li><\/ul>\n\n\n\n<p>QWorker \u4e2d\u7684 MsgWaitForEvent \u5185\u90e8\u4f7f\u7528\u4e86\u5b83\uff0c\u540e\u7eed\u7248\u672c\u4f1a\u66f4\u65b0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bf9\u4e8e TEvent \u6765\u8bf4\uff0c\u5982\u679c\u662f\u8c03\u7528 W [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","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":[],"class_list":["post-5304","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-qdac","category-qworker"],"views":2806,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5304","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=5304"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5304\/revisions"}],"predecessor-version":[{"id":5305,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5304\/revisions\/5305"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}