Skip to content

Commit

Permalink
Update MicrosoftStoreUpdateService.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
d2dyno1 committed Oct 19, 2024
1 parent 8c1f8ae commit ebe5b16
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ public async Task<IResult> UpdateAsync(IProgress<double>? progress, Cancellation

private async Task<bool> SetStoreContextAsync()
{
_storeContext ??= await Task.Run(StoreContext.GetDefault);
if (_storeContext is null)
{
_storeContext = await Task.Run(StoreContext.GetDefault);
if (_storeContext is not null)
WinRT_InitializeObject(_storeContext);
}

return _storeContext is not null;
}

Expand All @@ -114,5 +120,14 @@ private static AppUpdateResultType GetAppUpdateResultType(StorePackageUpdateStat
_ => AppUpdateResultType.None
};
}

private static void WinRT_InitializeObject(object obj)
{
_ = obj;
#if WINDOWS
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.Instance?.MainWindow);
WinRT.Interop.InitializeWithWindow.Initialize(obj, hwnd);
#endif
}
}
}

0 comments on commit ebe5b16

Please sign in to comment.