@@ -983,14 +983,13 @@ private static object GetPackageManagerRoot()
983983
984984 private static Task WaitForOperationAsync ( object listOp , TimeSpan timeout )
985985 {
986- // Check immediately — operation may already be done
987986 if ( listOp == null || _listOperationType == null )
988987 return Task . CompletedTask ;
989988
990989 var prop = _listOperationType . GetProperties (
991990 BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance )
992991 . FirstOrDefault ( p => p . Name == "isInProgress" ) ;
993- if ( prop == null || ! ( bool ) ( prop . GetValue ( listOp ) ?? false ) )
992+ if ( prop == null )
994993 return Task . CompletedTask ;
995994
996995 var tcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
@@ -999,33 +998,10 @@ private static Task WaitForOperationAsync(object listOp, TimeSpan timeout)
999998
1000999 void Tick ( )
10011000 {
1002- if ( tcs . Task . IsCompleted )
1003- {
1004- EditorApplication . update -= Tick ;
1005- return ;
1006- }
1001+ if ( tcs . Task . IsCompleted ) { EditorApplication . update -= Tick ; return ; }
1002+ if ( frameCount ++ % 30 != 0 ) return ;
10071003
1008- // Check every ~30 frames (~0.5s at 60fps)
1009- if ( ++ frameCount % 30 != 0 )
1010- return ;
1011-
1012- if ( ( DateTime . UtcNow - start ) > timeout )
1013- {
1014- EditorApplication . update -= Tick ;
1015- tcs . TrySetResult ( true ) ;
1016- return ;
1017- }
1018-
1019- try
1020- {
1021- bool isInProgress = ( bool ) ( prop . GetValue ( listOp ) ?? false ) ;
1022- if ( ! isInProgress )
1023- {
1024- EditorApplication . update -= Tick ;
1025- tcs . TrySetResult ( true ) ;
1026- }
1027- }
1028- catch
1004+ if ( ( DateTime . UtcNow - start ) > timeout || ! ( bool ) ( prop . GetValue ( listOp ) ?? false ) )
10291005 {
10301006 EditorApplication . update -= Tick ;
10311007 tcs . TrySetResult ( true ) ;
@@ -1038,26 +1014,14 @@ void Tick()
10381014
10391015 private static Task WaitForDownloadAsync ( long productId , TimeSpan timeout )
10401016 {
1041- // Check once immediately — download may already be complete
1042- var ( _, _, alreadyDone , earlyError ) = GetDownloadState ( productId ) ;
1043- if ( alreadyDone || ! string . IsNullOrEmpty ( earlyError ) )
1044- return Task . CompletedTask ;
1045-
10461017 var tcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
10471018 var start = DateTime . UtcNow ;
10481019 int frameCount = 0 ;
10491020
10501021 void Tick ( )
10511022 {
1052- if ( tcs . Task . IsCompleted )
1053- {
1054- EditorApplication . update -= Tick ;
1055- return ;
1056- }
1057-
1058- // Check every ~30 frames (~0.5s at 60fps)
1059- if ( ++ frameCount % 30 != 0 )
1060- return ;
1023+ if ( tcs . Task . IsCompleted ) { EditorApplication . update -= Tick ; return ; }
1024+ if ( frameCount ++ % 30 != 0 ) return ;
10611025
10621026 if ( ( DateTime . UtcNow - start ) > timeout )
10631027 {
@@ -1066,16 +1030,8 @@ void Tick()
10661030 return ;
10671031 }
10681032
1069- try
1070- {
1071- var ( _, _, completed , error ) = GetDownloadState ( productId ) ;
1072- if ( completed || ! string . IsNullOrEmpty ( error ) )
1073- {
1074- EditorApplication . update -= Tick ;
1075- tcs . TrySetResult ( true ) ;
1076- }
1077- }
1078- catch
1033+ var ( _, _, completed , error ) = GetDownloadState ( productId ) ;
1034+ if ( completed || ! string . IsNullOrEmpty ( error ) )
10791035 {
10801036 EditorApplication . update -= Tick ;
10811037 tcs . TrySetResult ( true ) ;
0 commit comments