-
Notifications
You must be signed in to change notification settings - Fork 1.2k
A way to handle exceptions from ValueChangedEventManager #10654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As your stacktrace above, the main reason is the UIA (UI Automation) module in system has the exception or the UIA state in WPF be error. As your stacktrace above, we can find this exception be raise in shutdown. Could you provide the repro demo? |
To reproduce:
The problem is that When (It is not an issue of UIA. UIA may not be able to compare elements for various reasons: timeout, element no longer exists, ...) |
@n9 Look like break in wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/ValueChangedEventManager.cs Line 492 in 2a8258a
Can I know your I re-read the code, but I can not find any ways to remove it without call the Equals method.
Yes, I agree with you. |
Sure! public override bool Equals(object? obj) => obj is AutomationElement element && Equals(element);
public bool Equals(AutomationElement? other) => other is not null && Automation.Native.CompareElements(Native, other.Native) != 0;
public override int GetHashCode() => RuntimeId?.GetHashCode() ?? 0; Note:
What about using |
@n9 Yeah, but I do not think you want to put the ReferenceEqualityComparer to your Equals method. And I do not think the |
Yes, the purpose of the
The But I do not know if WPF and .NET teams would prefer to just change the WPF or to extend the |
I do not think so. I do not think this proposal can pass. |
WPF uses the
ValueChangedEventManager
to track .NET objects that do not implement theINotifyPropertyChanged
interface. There is already an issue to add a runtime switch option to disable theValueChangedEventManager
(#10148).This issue is not about disabling the
ValueChangedEventManager
completely, but about being able to handle an exception when for exampleEquals
(used inConcurrentDictionary`2.TryGetValue
) throws anException
, as in the following example, where the exception is caused by the state of COM objects:The text was updated successfully, but these errors were encountered: