File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change 44
55using System ;
66using System . Threading ;
7+ using System . Threading . Tasks ;
78using Microsoft . CommandPalette . Extensions . Toolkit ;
89using PowerToys . Interop ;
910
@@ -21,15 +22,21 @@ public ToggleFindMyMouseCommand()
2122
2223 public override CommandResult Invoke ( )
2324 {
24- try
25+ // Delay the trigger so the Command Palette dismisses first
26+ _ = Task . Run ( async ( ) =>
2527 {
26- using var evt = new EventWaitHandle ( false , EventResetMode . AutoReset , Constants . FindMyMouseTriggerEvent ( ) ) ;
27- evt . Set ( ) ;
28- return CommandResult . Dismiss ( ) ;
29- }
30- catch ( Exception ex )
31- {
32- return CommandResult . ShowToast ( $ "Failed to trigger Find My Mouse: { ex . Message } ") ;
33- }
28+ await Task . Delay ( 200 ) . ConfigureAwait ( false ) ;
29+ try
30+ {
31+ using var evt = new EventWaitHandle ( false , EventResetMode . AutoReset , Constants . FindMyMouseTriggerEvent ( ) ) ;
32+ evt . Set ( ) ;
33+ }
34+ catch
35+ {
36+ // Ignore errors in background task
37+ }
38+ } ) ;
39+
40+ return CommandResult . Dismiss ( ) ;
3441 }
3542}
You can’t perform that action at this time.
0 commit comments