2017-04-18 07:52:04 +08:00
|
|
|
## WPF DispatcherSynchronizationContext.CreateCopy now returns a new copy instead of the current instance
|
2017-04-06 04:52:19 +08:00
|
|
|
|
|
|
|
### Scope
|
|
|
|
Minor
|
|
|
|
|
|
|
|
### Version Introduced
|
|
|
|
4.5
|
|
|
|
|
|
|
|
### Source Analyzer Status
|
|
|
|
Available
|
|
|
|
|
|
|
|
### Change Description
|
2017-04-21 02:19:05 +08:00
|
|
|
|
|
|
|
In the .NET Framework 4,
|
|
|
|
<xref:System.Windows.Threading.DispatcherSynchronizationContext.CreateCopy>
|
|
|
|
returned a reference to the current instance, primarily as a performance
|
|
|
|
optimization. In the .NET Framework 4.5, it returns a new instance which makes
|
|
|
|
it possible for the first time to conclude that equal references indicate the
|
|
|
|
executing thread is in the correct synchronization context. It is unlikely that
|
|
|
|
code that checks the identity of these references will be affected, but because
|
|
|
|
of the change, code that calls
|
|
|
|
<xref:System.Windows.Threading.DispatcherSynchronizationContext.CreateCopy>
|
|
|
|
should be tested as part of migration to the .NET Framework 4.5 or newer.
|
2017-04-06 04:52:19 +08:00
|
|
|
|
|
|
|
- [ ] Quirked
|
|
|
|
- [ ] Build-time break
|
|
|
|
|
|
|
|
### Recommended Action
|
2017-04-21 02:19:05 +08:00
|
|
|
|
|
|
|
Be aware that
|
|
|
|
<xref:System.Windows.Threading.DispatcherSynchronizationContext.CreateCopy>
|
|
|
|
will now return a new
|
|
|
|
<xref:System.Threading.SynchronizationContext?displayProperty=name> object.
|
|
|
|
Previously, code that used equivalence of references generated this way was not
|
|
|
|
actually checking whether it was in the proper context, but does when built
|
2018-03-01 08:06:28 +08:00
|
|
|
against .NET Framework 4.5 or later. While unlikely to cause issues, exercising the
|
2017-04-21 02:19:05 +08:00
|
|
|
affected code paths should be enough to determine if this poses any problem.
|
2017-04-06 04:52:19 +08:00
|
|
|
|
|
|
|
### Affected APIs
|
|
|
|
* `M:System.Windows.Threading.DispatcherSynchronizationContext.CreateCopy`
|
|
|
|
|
|
|
|
### Category
|
|
|
|
Windows Presentation Foundation (WPF)
|
|
|
|
|
2017-04-18 07:52:04 +08:00
|
|
|
<!-- breaking change id: 38 -->
|