Skip to content

Fix UI thread blocking and potential deadlocks in NotificationService and MainWindow - #212

Open
bajixx-19 wants to merge 1 commit into
IgorMundstein:mainfrom
bajixx-19:fix/ui-thread-async-dispatch
Open

bajixx-19 wants to merge 1 commit into
IgorMundstein:mainfrom
bajixx-19:fix/ui-thread-async-dispatch

Conversation

@bajixx-19

Copy link
Copy Markdown

Summary

Fixes potential UI freezes and deadlocks between background worker threads and the WPF UI thread by using asynchronous Dispatcher.BeginInvoke, a non-blocking DispatcherTimer during shutdown, and cooperative waiting during memory monitoring.

Changes

  • NotificationService: Replaced synchronous Dispatcher.Invoke with Dispatcher.BeginInvoke in Loading, StartRotationAnimation, and StopRotationAnimation so background threads do not block waiting on UI updates.
  • MainWindow: Replaced Thread.Sleep(1000) on the UI thread during shutdown with a DispatcherTimer to prevent window freezing.
  • MainViewModel: Added cooperative wait (WaitOne(1000)) in MonitorComputer when IsBusy is true to prevent CPU spin-looping.

Additional Notes

  • Tested locally on Windows: UI remains responsive, tray icon rotates smoothly, and no deadlocks occur during optimization.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant