@@ -40,16 +40,15 @@ public async Task InvokeAsync(AuthWorker worker, CancellationToken cancellationT
4040 {
4141 _logger . LogDebug ( "{Message}" , nameof ( ClientRunner ) ) ;
4242
43- _subscriber ? . Dispose ( ) ;
43+ await UpdateClientAsync ( null , cancellationToken ) ;
44+ await BlockClientAsync ( null , cancellationToken ) ;
4445
46+ _subscriber ? . Dispose ( ) ;
4547 _subscriber = _redis . Subscribe ( new [ ]
4648 {
4749 _config . Queues [ ConfigSettings . QUEUES_CLIENT_CHANGE_EVENT ]
4850 } , Handler ) ;
4951
50- await UpdateClientAsync ( null , cancellationToken ) ;
51- await BlockClientAsync ( null , cancellationToken ) ;
52-
5352 return ;
5453
5554 void Handler ( string s , object o )
@@ -60,9 +59,11 @@ void Handler(string s, object o)
6059
6160 private async Task UpdateClientAsync ( string ? ids , CancellationToken cancellationToken = default )
6261 {
62+ var lockerKey = ids . IsEmpty ( ) ? nameof ( UpdateClientAsync ) : nameof ( UpdateClientAsync ) + "/" + ids ;
63+
6364 try
6465 {
65- await _locker . WaitAsync ( nameof ( UpdateClientAsync ) ) ;
66+ await _locker . WaitAsync ( lockerKey ) ;
6667
6768 _logger . LogInformation ( nameof ( UpdateClientAsync ) ) ;
6869
@@ -103,15 +104,17 @@ private async Task UpdateClientAsync(string? ids, CancellationToken cancellation
103104 }
104105 finally
105106 {
106- _locker . Release ( nameof ( BlockClientAsync ) ) ;
107+ _locker . Release ( lockerKey ) ;
107108 }
108109 }
109110
110111 private async Task BlockClientAsync ( string ? ids , CancellationToken cancellationToken = default )
111112 {
113+ var lockerKey = ids . IsEmpty ( ) ? nameof ( BlockClientAsync ) : nameof ( BlockClientAsync ) + "/" + ids ;
114+
112115 try
113116 {
114- await _locker . WaitAsync ( nameof ( BlockClientAsync ) ) ;
117+ await _locker . WaitAsync ( lockerKey ) ;
115118
116119 _logger . LogInformation ( nameof ( BlockClientAsync ) ) ;
117120
@@ -151,7 +154,7 @@ private async Task BlockClientAsync(string? ids, CancellationToken cancellationT
151154 }
152155 finally
153156 {
154- _locker . Release ( nameof ( BlockClientAsync ) ) ;
157+ _locker . Release ( lockerKey ) ;
155158 }
156159 }
157160
0 commit comments