{"id":2843,"date":"2019-09-11T00:51:28","date_gmt":"2019-09-10T15:51:28","guid":{"rendered":"http:\/\/okamurax.com\/?p=2843"},"modified":"2019-09-11T00:51:28","modified_gmt":"2019-09-10T15:51:28","slug":"c-%e9%9d%9e%e5%90%8c%e6%9c%9fthread-threadpool","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2843","title":{"rendered":"C# \u975e\u540c\u671fThread\/ThreadPool"},"content":{"rendered":"<pre class=\"lang:c# decode:true \">public Form1()\r\n{\r\n    InitializeComponent();\r\n\r\n    \/\/ Thread \u30e1\u30bd\u30c3\u30c9\r\n    var t1 = new System.Threading.Thread(Test1);\r\n    t1.Start();\r\n\r\n    \/\/ Thread \u30e9\u30e0\u30c0\r\n    new System.Threading.Thread(() =&gt;\r\n    {\r\n        MessageBox.Show(\"hello world1\");\r\n\r\n        this.Invoke((Action)(()=&gt; {\r\n            button1.Text = \"1\";\r\n        }));\r\n        \/\/ \u5225\u30b9\u30ec\u30c3\u30c9\u304b\u3089UI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u3001Invoke\u304b\u3089\r\n\r\n    }).Start();\r\n\r\n    \/\/ \u30b9\u30ec\u30c3\u30c9\u306f\u9ad8\u30b3\u30b9\u30c8\u306a\u306e\u3067\u4f7f\u3044\u56de\u3059\u3002ThreadPool\r\n\r\n    System.Threading.ThreadPool.QueueUserWorkItem( _ =&gt;\r\n    {\r\n        MessageBox.Show(\"hello world2\");\r\n    }, null);\r\n    \/\/ QueueUserWorkItem\r\n    \/\/ QueueUserWorkItem(\u5b9f\u884c\u3059\u308b\u30e1\u30bd\u30c3\u30c9, \u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570)\r\n    \/\/ \u5b9f\u884c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306fWaitCallback\u30c7\u30ea\u30b2\u30fc\u30c8\u578b = delegate void WaitCallback (Object state)\r\n}\r\n\r\nprivate void Test1() { }<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>public Form1() { InitializeComponent(); \/\/ Thread \u30e1\u30bd\u30c3\u30c9 var t1 = new System.Threading.Thread(Test1); t1.Start() &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2843\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u975e\u540c\u671fThread\/ThreadPool&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-2843","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2843"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2843\/revisions"}],"predecessor-version":[{"id":2844,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2843\/revisions\/2844"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}