dotnet / dotnet/wpf

ICommand.CanExecuteChanged should handle the execution on the correct thread

Open
#4,473 6 comments 0 reactions 0 assignees View on GitHub
.NET Framework
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

NET Core Version: 5.0.201
Windows version: Windows 10 Entrprise 190
Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
**Problem description:
Currently the registration to the ICommand.CanExecuteChanged event doesn't consider that the triggering of the command state change can happen from a background thread and throws an InvalidOperationException.

Considering that the registration to the command even happens in the control it should ensure the execution of the refresh will happen on the thread of the control.

**Actual behavior: Exception is thrown when the CanExecuteChanged is called from not the Owner thread.

**Expected behavior: The state refresh should be executed without any problems

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.