Invoke in ElementUtil and ElementProxy cause unnecessary delegate allocations
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
_I might bundle this up with some Dispatcher improvements to support generic invocations at least for internal use, so it would be a bigger PR. We will see, won't be right away._
### Description
The `Invoke` method from `ElementUtil` is causing unnecessary allocations due to the attempt to catch exceptions from another thread (if invoked on) and re-throw on the current thread. This further comes the from already allocating delegates inside `ElementProxy` that use this `Invoke` exclusively.
### Showcase

### Repro
Note: This repro is specifically crafted to highlight an issue like this.
https://github.com/h3xds1nz/UIAPerformancePitfalls
Contributor guide
Assessment
This issue has not been assessed yet.