Skip to content
This repository was archived by the owner on Feb 12, 2021. It is now read-only.

Fix deadlock in event handler for thumbnail tap - #1

Open
anirudhsanthiar wants to merge 1 commit into
microsoft:masterfrom
anirudhsanthiar:deadlockFix
Open

Fix deadlock in event handler for thumbnail tap#1
anirudhsanthiar wants to merge 1 commit into
microsoft:masterfrom
anirudhsanthiar:deadlockFix

Conversation

@anirudhsanthiar

Copy link
Copy Markdown

Lines 114-116 of LensBlurApp/Pages/GalleryPage.xaml.cs say
var task = photo.File.OpenReadAsync().AsTask();
task.Wait();

The Wait on line 114 will block the UI thread. The thread can proceed
only when the Task returned by OpenReadAsync().AsTask() competes.
However, the continuation completing this task will
be posted to the captured synchronization context from the UI thread,
which is blocked, and will never run. This results in deadlock.
This patch replaces task.Wait() by await task, and marks the event
handler async. Avoiding the blocking wait fixes the deadlock.

Lines 114-116 of LensBlurApp/Pages/GalleryPage.xaml.cs say
var task = photo.File.OpenReadAsync().AsTask();
task.Wait();

The Wait on line 114 will block the UI thread. The thread can proceed
only when the Task returned by OpenReadAsync().AsTask() competes.
However, the continuation completing this task will
be posted to the captured synchronization context from the UI thread,
which is blocked, and will never run. This results in deadlock.
This patch replaces task.Wait() by await task, and marks the event
handler async. Avoiding the blocking wait fixes the deadlock.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant