{"id":4126,"date":"2019-09-21T17:09:20","date_gmt":"2019-09-22T00:09:20","guid":{"rendered":"http:\/\/mattfife.com\/?p=4126"},"modified":"2019-09-21T17:20:50","modified_gmt":"2019-09-22T00:20:50","slug":"c-app-hangs-when-bitmapdecoder-createasync-is-called","status":"publish","type":"post","link":"https:\/\/mattfife.com\/?p=4126","title":{"rendered":"C# App hangs when BitmapDecoder.CreateAsync is called"},"content":{"rendered":"\n<p>Calling ASync functions from UI event handling routines\/the main UI thread in C# turns out to require some basic knowledge to avoid getting into deadlocks. I sort of jumped in without doing much learning, so here were some of my learning resources as I made the inevitable mistakes:<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/12507749\/winrt-app-hangs-when-bitmapdecoder-createasyncstream-is-called\">https:\/\/stackoverflow.com\/questions\/12507749\/winrt-app-hangs-when-bitmapdecoder-createasyncstream-is-called<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/8bed034e-a8f6-4322-a801-79f014815dd9\/bitmapencodercreateasync-never-returns?forum=winappswithcsharp\">https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/8bed034e-a8f6-4322-a801-79f014815dd9\/bitmapencodercreateasync-never-returns?forum=winappswithcsharp<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/12235085\/winrt-loading-static-data-with-getfilefromapplicationuriasync\">https:\/\/stackoverflow.com\/questions\/12235085\/winrt-loading-static-data-with-getfilefromapplicationuriasync<\/a><\/p>\n\n\n\n<p>Debugging tips:<\/p>\n\n\n\n<figure class=\"wp-block-embed-wordpress wp-block-embed is-type-wp-embed is-provider-parallel-programming-with-net\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"rXva0rZTJj\"><a href=\"https:\/\/devblogs.microsoft.com\/pfxteam\/psychic-debugging-of-async-methods\/\">Psychic Debugging of Async Methods<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Psychic Debugging of Async Methods&#8221; &#8212; .NET Parallel Programming\" src=\"https:\/\/devblogs.microsoft.com\/pfxteam\/psychic-debugging-of-async-methods\/embed\/#?secret=LViuRXs0AO#?secret=rXva0rZTJj\" data-secret=\"rXva0rZTJj\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><a href=\"https:\/\/medium.com\/bynder-tech\/c-why-you-should-use-configureawait-false-in-your-library-code-d7837dce3d7f\">https:\/\/medium.com\/bynder-tech\/c-why-you-should-use-configureawait-false-in-your-library-code-d7837dce3d7f<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.threading.tasks.task-1.result?view=netframework-4.8\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.threading.tasks.task-1.result?view=netframework-4.8<\/a><\/p>\n\n\n\n<p>C# and Universal Windows App file handling:<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/get-started\/fileio-learning-track\">https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/get-started\/fileio-learning-track<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/files\/file-access-permissions\">https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/files\/file-access-permissions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Calling ASync functions from UI event handling routines\/the main UI thread in C# turns out to require some basic knowledge to avoid getting into deadlocks. I sort of jumped in without doing much learning, so here were some of my learning resources as I made the inevitable mistakes: https:\/\/stackoverflow.com\/questions\/12507749\/winrt-app-hangs-when-bitmapdecoder-createasyncstream-is-called https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/8bed034e-a8f6-4322-a801-79f014815dd9\/bitmapencodercreateasync-never-returns?forum=winappswithcsharp https:\/\/stackoverflow.com\/questions\/12235085\/winrt-loading-static-data-with-getfilefromapplicationuriasync Debugging tips: https:\/\/medium.com\/bynder-tech\/c-why-you-should-use-configureawait-false-in-your-library-code-d7837dce3d7f https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.threading.tasks.task-1.result?view=netframework-4.8 C# and Universal Windows App file handling: https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/get-started\/fileio-learning-track https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/files\/file-access-permissions<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,5],"tags":[],"class_list":["post-4126","post","type-post","status-publish","format-standard","hentry","category-technicalprogramming","category-technical"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4WECr-14y","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/4126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4126"}],"version-history":[{"count":2,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/4126\/revisions"}],"predecessor-version":[{"id":4128,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/4126\/revisions\/4128"}],"wp:attachment":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}