Open from URL: marshal download timer tick to UI thread#11652
Merged
Conversation
DownloadVideoFromUrlViewModel uses a System.Timers.Timer to poll the background download task. Its Elapsed handler runs on a thread-pool thread but writes observable properties bound to the UI (StatusText, Error) and closes the window. Touching bound state off the UI thread can throw "call from invalid thread" or leave the UI inconsistent. Marshal the whole tick to the UI thread via Dispatcher.UIThread.Post. Close() is now always called on the UI thread, so it no longer needs its own Post. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
DownloadVideoFromUrlViewModelpolls the background download task with aSystem.Timers.Timer. TheElapsedhandler fires on a thread-pool thread but writes[ObservableProperty]values bound to the UI (StatusText,Error) and closes the window. Touching bound state off the UI thread can throw"Call from invalid thread"or leave the UI in an inconsistent state.This wraps the tick in
Dispatcher.UIThread.Post(...)so all of it runs on the UI thread. SinceClose()is now always called on the UI thread, its own innerPostis removed.Why
Tightens a real thread-affinity smell in the "Open video from URL → Download and open" flow. Surfaced while investigating #11644 (freeze after opening a video from a URL with subtitles). This is not confirmed to be the cause of that report — the leading hypothesis there is the embedded video player rendering a specific container/codec — but the cross-thread property writes are a genuine latent bug worth fixing regardless.
Testing
dotnet build UI.csprojsucceeds with 0 warnings / 0 errors.🤖 Generated with Claude Code