dotnet / dotnet/winforms

Enable cross-thread checks by default

Open
#832 0 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

Cross-thread checks are disabled by default in Winforms, unless a debugger is attached or `Control.CheckForIllegalCrossThreadCalls` is explicitly set to true. I understand that back in the days it had been designed this way because it was a huge breaking change for .net 1.1 applications.

Now the landscape has changed quite a bit, and developers coming from WPF take those checks for granted and wrongly assume that they're activated by default in Winforms:
- https://stackoverflow.com/questions/3972727/why-is-cross-thread-operation-exception-not-thrown-while-running-exe-in-bin-debu
- https://stackoverflow.com/questions/55759792/why-are-we-allowed-to-modify-the-form-title-from-a-thread-pool-thread

I think this is a nice opportunity to fix this behavior and set `CheckForIllegalCrossThreadCalls` to true by default, as most developers would expect nowadays.

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.