Guys, WPF project is not accepting this property definition when starting a thread. Anybody knows the equivalent of the following in WPF?
Control.CheckForIllegalCrossThreadCalls = False
Thanks in advance!
Guys, WPF project is not accepting this property definition when starting a thread. Anybody knows the equivalent of the following in WPF?
Control.CheckForIllegalCrossThreadCalls = False
Thanks in advance!
In WPF the responsibility of checking for illegal cross thread calls rests with the Dispatcher object via the CheckAccess() member. Objects like DependencyObject use their associated Dispatcher to check for an illegal thread access on almost all API calls.
Unlike WinForms, there is no way to disable this check in WPF. It is on by default and cannot be disabled.
As to why this is the case (bit of speculation here). The CheckForIllegalCrossThreadCalls member was added in .net 2.0. The reason was that accessing a control from a different thread was already illegal, there was just no enforcement of this. This resulted in lots of unpredictable user scenarios as instead of proactively crashing, the control would have unpredictable behvaior.
In 2.0, the WinForms team added the CheckForIllegalCrossThreadCalls as a way of proactively preventing these scenarios from happennig. But because some people were getting away with it they had to insert a way to turn it off in order fro applications to be backwards compatible.
If you need to turn this off, there is a bug in your code. You would be much better served by finding and fixing the bug as opposed to disabled the check.