Skip to content

Commit f616232

Browse files
authored
Feature: Improved (but hacky) context menu loading (#11966)
1 parent 24617a6 commit f616232

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Files.App/App.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Files.App.ServicesImplementation;
1414
using Files.App.ServicesImplementation.DateTimeFormatter;
1515
using Files.App.ServicesImplementation.Settings;
16+
using Files.App.Shell;
1617
using Files.App.Storage.NativeStorage;
1718
using Files.App.UserControls.MultitaskingControl;
1819
using Files.App.ViewModels;
@@ -139,7 +140,8 @@ await Task.WhenAll(
139140

140141
await Task.WhenAll(
141142
JumpListHelper.InitializeUpdatesAsync(),
142-
addItemService.GetNewEntriesAsync()
143+
addItemService.GetNewEntriesAsync(),
144+
ContextMenu.WarmUpQueryContextMenuAsync()
143145
);
144146

145147
FileTagsHelper.UpdateTagsDb();

src/Files.App/Shell/ContextMenu.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ public async Task InvokeItem(int itemID)
163163
}
164164
}
165165

166+
public static async Task WarmUpQueryContextMenuAsync()
167+
{
168+
var thread = new ThreadWithMessageQueue();
169+
await thread.PostMethod(() =>
170+
{
171+
// Create a dummy context menu for warming up
172+
var shellItem = ShellFolderExtensions.GetShellItemFromPathOrPidl("C:\\");
173+
Shell32.IContextMenu menu = shellItem.Parent.GetChildrenUIObjects<Shell32.IContextMenu>(default, shellItem);
174+
menu.QueryContextMenu(User32.CreatePopupMenu(), 0, 1, 0x7FFF, Shell32.CMF.CMF_NORMAL);
175+
});
176+
thread.Dispose();
177+
}
178+
166179
#endregion FactoryMethods
167180

168181
private void EnumMenuItems(

0 commit comments

Comments
 (0)