{"id":5543,"date":"2022-07-21T14:04:03","date_gmt":"2022-07-21T06:04:03","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=5543"},"modified":"2022-07-21T17:46:41","modified_gmt":"2022-07-21T09:46:41","slug":"%e6%95%99%e7%a8%8bzasync-%e5%bc%82%e6%ad%a5%e7%bc%96%e7%a8%8b%e4%b9%8b%e5%9b%9b%ef%bc%9a%e8%af%b7%e8%ae%b0%e4%bd%8f%e5%8c%bf%e5%90%8d%e5%87%bd%e6%95%b0%e6%98%af%e4%b8%80%e4%b8%aa%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=5543","title":{"rendered":"[\u6559\u7a0b]ZAsync \u5f02\u6b65\u7f16\u7a0b\u4e4b\u56db\uff1a\u5173\u4e8e\u533f\u540d\u51fd\u6570\u548c\u7ebf\u7a0b\u53d8\u91cf"},"content":{"rendered":"\n<p><strong>[\u533f\u540d\u51fd\u6570]<\/strong><\/p>\n\n\n\n<p>\u5728 Delphi \u4e2d\uff0c\u533f\u540d\u51fd\u6570\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u8fd9\u4e00\u70b9\u6211\u4eec\u5728\u524d\u9762\u7684\u6587\u7ae0\u4e2d\u5df2\u7ecf\u505a\u51fa\u4e86\u660e\u786e\u7684\u63d0\u793a\u3002\u4ece\u524d\u9762\u7684\u5206\u6790\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff1a<\/p>\n\n\n\n<p>1\u3001\u5728\u533f\u540d\u51fd\u6570\u4e2d\u4f7f\u7528\u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u5b9e\u9645\u5185\u5b58\u662f\u5bf9\u5e94\u7684\u7ed3\u6784\u6210\u5458\u7684\u4f4d\u7f6e\uff0c\u800c\u4e0d\u662f\u5f53\u524d\u51fd\u6570\u6808\u4e0a\u7684\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>2\u3001\u5982\u679c\u4e00\u4e2a\u63a5\u53e3\u5c40\u90e8\u53d8\u91cf\u88ab\u533f\u540d\u51fd\u6570\u5f15\u7528\uff0c\u90a3\u4e48\u5e94\u8be5\u5728\u7528\u5b8c\u540e\uff0c\u8bbe\u7f6e\u4e3a\u7a7a\uff0c\u4ee5\u4fbf\u51cf\u5c0f\u5f15\u7528\u8ba1\u6570\uff0c\u907f\u514d\u5185\u5b58\u6cc4\u9732\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\uff0c\u4e00\u4e2a\u826f\u597d\u7684\u7f16\u7801\u4e60\u60ef\u662f\u59cb\u7ec8\u5728\u4e0d\u4f7f\u7528\u63a5\u53e3\u65f6\uff0c\u5c06\u5176\u8d4b\u503c\u4e3a\u7a7a\uff0c\u800c\u4e0d\u662f\u7b49\u5f85\u5176\u88ab\u81ea\u52a8\u6e05\u7406\u3002<\/p>\n\n\n\n<p><strong>[\u7ebf\u7a0b\u53d8\u91cf]<\/strong><\/p>\n\n\n\n<p>\u7ebf\u7a0b\u53d8\u91cf\u5982\u679c\u662f\u7b80\u5355\u7c7b\u578b\uff0c\u90a3\u4e48\u5b83\u4f1a\u968f\u7740\u7ebf\u7a0b\u7684\u91ca\u653e\uff0c\u800c\u88ab\u64cd\u4f5c\u7cfb\u7edf\u91ca\u653e\u3002\u4f46\u7ebf\u7a0b\u53d8\u91cf\u662f\u6307\u9488\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u5982\u63a5\u53e3\/\u5bf9\u8c61\/\u8bb0\u5f55\u7b49\u590d\u5408\u7c7b\u578b\uff0c\u5b9e\u9645\u4e0a\u5176\u662f\u5728\u5806\u4e0a\u5206\u914d\u7684\u5185\u5b58\uff0c\u5e76\u4e0d\u4f1a\u968f\u7740\u7ebf\u7a0b\u7684\u91ca\u653e\u800c\u91ca\u653e\uff0c\u9700\u8981\u6211\u4eec\u4eba\u5de5\u8fdb\u884c\u5904\u7406\u3002TZAsync \u5bf9\u8fd9\u4e9b\u7c7b\u578b\u7684\u5bf9\u8c61\u8fdb\u884c\u4e86\u4e00\u4e9b\u5904\u7406\uff0c\u4ee5\u51cf\u5c11\u60a8\u81ea\u5df1\u7ef4\u62a4\u7684\u4ee3\u7801\u91cf\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>TZAsync.RegisterThreadLeak \u6ce8\u518c\u4e00\u4e2a\u7ebf\u7a0b\u4e2d\u5206\u914d\u7684\u5bf9\u8c61\u6216\u63a5\u53e3\uff0c\u800c\u8fd9\u4e2a\u63a5\u53e3\u6216\u5bf9\u8c61\u5728\u7ebf\u7a0b\u5f02\u5e38\u4e2d\u6b62\u65f6\uff0c\u65e0\u6cd5\u88ab\u53ca\u65f6\u91ca\u653e\u3002<\/li><li>TZAsync.UnregisterThreadLeak \u7528\u6765\u79fb\u9664\u7ecf\u7531\u524d\u8ff0\u63a5\u53e3\u6ce8\u518c\u7684\u7684\u5bf9\u8c61\u6216\u63a5\u53e3\uff0c\u6539\u7531\u7528\u6237\u81ea\u884c\u91ca\u653e<\/li><\/ul>\n\n\n\n<p>\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>threadvar MyList:TList;\n....\nMyList:=TList.Create;\nTZAsync.RegisterThreadLeak(MyList);\n...<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4e0a\u8ff0\u4ee3\u7801\u5728\u7ebf\u7a0b\u4e2d\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0c\u7ebf\u7a0b\u7ed3\u675f\u65f6\uff0c\u5982\u679c\u7528\u6237\u6ca1\u6709\u624b\u52a8\u91ca\u653e MyList \u5b9e\u4f8b\uff0c\u90a3\u4e48 TZAsync \u4f1a\u5728\u7ebf\u7a0b\u7ed3\u675f\u540e\uff0c\u81ea\u52a8\u68c0\u67e5\u5e76\u91ca\u653e MyList \u7684\u503c\uff0c\u4ece\u800c\u51cf\u5c11\u5185\u5b58\u6cc4\u9732\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u7684\u4ee3\u7801\u6b63\u5e38\u8fd0\u884c\uff0c\u5728\u6b63\u5e38\u7ebf\u7a0b\u7ed3\u675f\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u8c03\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u6765\u53d6\u6d88\u59d4\u6258\u7ba1\u7406\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>TZAsync.UnregisterThreadLeak(MyList);<\/code><\/pre>\n\n\n\n<p>\u63a5\u53e3\u540c\u7406\u5373\u53ef\uff0c\u4f46\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5982\u679c\u63a5\u53e3\u6709\u88ab\u975e\u7ebf\u7a0b\u53d8\u91cf\u5f15\u7528\uff0c\u90a3\u4e48\u7528\u6237\u4e0d\u5e94\u8be5\u59d4\u6258\u7ed9 TZAsync \u7ba1\u7406\u53d8\u91cf\u7684\u751f\u547d\u5468\u671f\u3002<\/li><li>TZAsync \u5bf9\u63a5\u53e3\u7684\u91ca\u653e\u662f\u91c7\u7528\u66b4\u529b\u51cf\u5c11\u5f15\u7528\u8ba1\u6570\u52300\u6765\u91ca\u653e\uff0c\u4f46\u5982\u679c\u8ba1\u6570\u5728\u8c03\u7528 _Release \u591a\u6b21\u540e\u6ca1\u6709\u53d8\u5316\uff0c\u5219\u4e0d\u4f1a\u5904\u7406\uff08\u6bd4\u5982 TComponentInterfaceDelegate \u5b9e\u73b0\u59cb\u7ec8\u8fd4\u56de-1\uff09 <\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>[\u533f\u540d\u51fd\u6570] \u5728 Delphi \u4e2d\uff0c\u533f\u540d [&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":[8],"tags":[],"class_list":["post-5543","post","type-post","status-publish","format-standard","hentry","category-delphi"],"views":1671,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5543","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=5543"}],"version-history":[{"count":5,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5543\/revisions"}],"predecessor-version":[{"id":5569,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5543\/revisions\/5569"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}