Skip to content

Commit 4abd776

Browse files
committed
Move WWAHost process creation into dispatcher
When the WWAHost.exe and Win32WebViewProcess.exe are created, they need to read information such as the networking permissions and enterprise ID. However, when those items are data bound they are done on the dispatcher thread (priority 8); however, the process is initialized prior to flushing the dispatcher queue. This then did not read the proper values during initialization (as they had not yet been changed by the dispatcher queue), even though they were set once the dispatcher had popped our frame to create the view. This change moves the process creation code from outside the dispatcher frame into the same location as the remainder of the initialization code. This will permit any mutations to properties through the dispatcher, such as data binding, prior to initialization.
1 parent 402677a commit 4abd776

File tree

1 file changed

+18
-18
lines changed
  • Microsoft.Toolkit.Win32/Microsoft.Toolkit.Win32.UI.Controls/WPF/WebView

1 file changed

+18
-18
lines changed

Microsoft.Toolkit.Win32/Microsoft.Toolkit.Win32.UI.Controls/WPF/WebView/WebView.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -723,27 +723,27 @@ protected override void Initialize()
723723

724724
Verify.AreEqual(_initializationState, InitializationState.IsInitializing);
725725

726-
if (_process == null)
727-
{
728-
var privateNetworkEnabled = !Dispatcher.CheckAccess()
729-
? Dispatcher.Invoke(() => IsPrivateNetworkClientServerCapabilityEnabled)
730-
: IsPrivateNetworkClientServerCapabilityEnabled;
731-
var enterpriseId = !Dispatcher.CheckAccess()
732-
? Dispatcher.Invoke(() => EnterpriseId)
733-
: EnterpriseId;
734-
735-
_process = new WebViewControlProcess(new WebViewControlProcessOptions
736-
{
737-
PrivateNetworkClientServerCapability = privateNetworkEnabled
738-
? WebViewControlProcessCapabilityState.Enabled
739-
: WebViewControlProcessCapabilityState.Disabled,
740-
EnterpriseId = enterpriseId
741-
});
742-
}
743-
744726
Dispatcher.InvokeAsync(
745727
async () =>
746728
{
729+
if (_process == null)
730+
{
731+
var privateNetworkEnabled = !Dispatcher.CheckAccess()
732+
? Dispatcher.Invoke(() => IsPrivateNetworkClientServerCapabilityEnabled)
733+
: IsPrivateNetworkClientServerCapabilityEnabled;
734+
var enterpriseId = !Dispatcher.CheckAccess()
735+
? Dispatcher.Invoke(() => EnterpriseId)
736+
: EnterpriseId;
737+
738+
_process = new WebViewControlProcess(new WebViewControlProcessOptions
739+
{
740+
PrivateNetworkClientServerCapability = privateNetworkEnabled
741+
? WebViewControlProcessCapabilityState.Enabled
742+
: WebViewControlProcessCapabilityState.Disabled,
743+
EnterpriseId = enterpriseId
744+
});
745+
}
746+
747747
Verify.IsNotNull(_process);
748748

749749
if (_webViewControl == null)

0 commit comments

Comments
 (0)