{"id":135,"date":"2006-08-24T14:14:35","date_gmt":"2006-08-24T19:14:35","guid":{"rendered":"http:\/\/bitpost.com\/news\/2006\/08\/24\/shorten-your-c-mfc-multithreading-learning-curve\/"},"modified":"2006-12-01T16:30:18","modified_gmt":"2006-12-01T21:30:18","slug":"shorten-your-c-mfc-multithreading-learning-curve","status":"publish","type":"post","link":"https:\/\/bitpost.com\/news\/2006\/shorten-your-c-mfc-multithreading-learning-curve\/","title":{"rendered":"Shorten your multithreading learning curve"},"content":{"rendered":"<p>Read <a href=\"http:\/\/www.flounder.com\/badprogram.htm\">this guy&#8217;s notes<\/a>.  Seriously.  Working out my own threading issues for STDJ&#8217;s purposes, I either came to the same conclusions, or should have.  Even though it&#8217;s &#8220;old skool MFC&#8221;, it has great advice that can be abstracted and applied to any multithreaded environment.  I&#8217;m keeping a <a href=\"http:\/\/bitpost.com\/news\/the-n-habits-of-highly-defective-windows-applications\/\">backup<\/a> of that page.<\/p>\n<p>My initial troubles came from trying to decipher the MSDN docs on how to start\/end a thread.  There are at least FOUR #*&#038;@% different ways to do it, and the docs are so bad they will make you go blind if you read them all.  After digging for a while, the guy at flounder.com has it right when he says only one is correct.  A quick peek at the Shareaza code base shows that they agree.  Upwards and onwards with AfxBeginThread()!<\/p>\n<p>Other issues that he helped me with were using the volatile keyword on shared (and properly locked) variables, and using ::PostMessage, not ::SendMessage, from thread to thread (I should have figured that one out, sigh&#8230;).<\/p>\n<p>If I get enough time I am hopeful about switching to <a href=\"http:\/\/www.boost.org\/doc\/html\/threads.html\">boost&#8217;s thread library<\/a> in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Read this guy&#8217;s notes. Seriously. Working out my own threading issues for STDJ&#8217;s purposes, I either came to the same conclusions, or should have. Even though it&#8217;s &#8220;old skool MFC&#8221;, it has great advice that can be abstracted and applied to any multithreaded environment. I&#8217;m keeping a backup of that page. My initial troubles came [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[7,4,8,10,6],"tags":[],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-hangthedj","category-projects","category-sharethedj","category-tricks-tips-tools","category-windows-projects"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9M11L-2b","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/comments?post=135"}],"version-history":[{"count":0,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}