| 5 | #include "redefgetcurrenttime.h" |
| 6 | |
| 7 | VisualTreeWatcher::VisualTreeWatcher(winrt::com_ptr<IUnknown> site, wil::unique_event_nothrow&& readyEvent) : |
| 8 | m_XamlDiagnostics(site.as<IXamlDiagnostics>()), |
| 9 | m_AppearanceService(winrt::make_self<TaskbarAppearanceService>()), |
| 10 | m_ReadyEvent(std::move(readyEvent)) |
| 11 | { |
| 12 | |
| 13 | // Calling AdviseVisualTreeChange from a separate thread solves some hangs. |
| 14 | std::thread([self_strong = get_strong()] |
| 15 | { |
| 16 | // AdviseVisualTreeChange is special-cased to bring us to the UI thread for the callback. |
| 17 | winrt::check_hresult(self_strong->m_XamlDiagnostics.as<IVisualTreeService3>()->AdviseVisualTreeChange(self_strong.get())); |
| 18 | self_strong->m_ReadyEvent.SetEvent(); |
| 19 | }).detach(); |
| 20 | } |
| 21 | |
| 22 | HRESULT VisualTreeWatcher::OnVisualTreeChange(ParentChildRelation relation, VisualElement element, VisualMutationType mutationType) try |
| 23 | { |