@@ -449,25 +449,38 @@ public static string EnsureSafeQueryString(string query)
449449 /// <summary>
450450 /// Enables GSudo cache for the current process
451451 /// </summary>
452+ private static bool _isCaching ;
452453 public static async Task CacheUACForCurrentProcess ( )
453454 {
454- Logger . Info ( "Caching admin rights for process id " + Environment . ProcessId ) ;
455- using Process p = new ( )
455+ while ( _isCaching ) await Task . Delay ( 100 ) ;
456+
457+ try
456458 {
457- StartInfo = new ProcessStartInfo
459+ _isCaching = true ;
460+ Logger . Info ( "Caching admin rights for process id " + Environment . ProcessId ) ;
461+ using Process p = new ( )
458462 {
459- FileName = CoreData . ElevatorPath ,
460- Arguments = "cache on --pid " + Environment . ProcessId + " -d 1" ,
461- UseShellExecute = false ,
462- RedirectStandardOutput = true ,
463- RedirectStandardError = true ,
464- RedirectStandardInput = true ,
465- CreateNoWindow = true ,
466- StandardOutputEncoding = Encoding . UTF8 ,
467- }
468- } ;
469- p . Start ( ) ;
470- await p . WaitForExitAsync ( ) ;
463+ StartInfo = new ProcessStartInfo
464+ {
465+ FileName = CoreData . ElevatorPath ,
466+ Arguments = "cache on --pid " + Environment . ProcessId + " -d 1" ,
467+ UseShellExecute = false ,
468+ RedirectStandardOutput = true ,
469+ RedirectStandardError = true ,
470+ RedirectStandardInput = true ,
471+ CreateNoWindow = true ,
472+ StandardOutputEncoding = Encoding . UTF8 ,
473+ }
474+ } ;
475+ p . Start ( ) ;
476+ await p . WaitForExitAsync ( ) ;
477+ _isCaching = false ;
478+ }
479+ catch ( Exception ex )
480+ {
481+ Logger . Error ( ex ) ;
482+ _isCaching = false ;
483+ }
471484 }
472485
473486 /// <summary>
0 commit comments