@@ -141,6 +141,34 @@ public async Task PooledLogicLooper_ShutdownAsyncFromLooperPool()
141141 Assert . True ( looperFactory . CreatedLoopers [ 3 ] . IsShutdownRequested ) ;
142142 }
143143
144+ [ Fact ]
145+ public async Task OperationsAfterDispose_ThrowObjectDisposedException ( )
146+ {
147+ var looperFactory = new FakeLogicLooperPoolLooperFactory ( ) ;
148+ var pool = new LogicLooperPool ( 60 , 4 , RoundRobinLogicLooperPoolBalancer . Instance , looperFactory ) ;
149+
150+ pool . Dispose ( ) ;
151+
152+ LogicLooperActionDelegate action = ( in LogicLooperActionContext _ ) => false ;
153+ LogicLooperActionWithStateDelegate < int > actionWithState = ( in LogicLooperActionContext _ , int _ ) => false;
154+ LogicLooperAsyncActionDelegate asyncAction = _ => ValueTask . FromResult ( false ) ;
155+ LogicLooperAsyncActionWithStateDelegate < int > asyncActionWithState = ( _ , _ ) => ValueTask . FromResult ( false ) ;
156+
157+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( action ) ; } ) ;
158+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( action , LooperActionOptions . Default ) ; } ) ;
159+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( actionWithState , 0 ) ; } ) ;
160+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( actionWithState , 0 , LooperActionOptions . Default ) ; } ) ;
161+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( asyncAction ) ; } ) ;
162+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( asyncAction , LooperActionOptions . Default ) ; } ) ;
163+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( asyncActionWithState , 0 ) ; } ) ;
164+ Assert . Throws < ObjectDisposedException > ( ( ) => { _ = pool . RegisterActionAsync ( asyncActionWithState , 0 , LooperActionOptions . Default ) ; } ) ;
165+ Assert . Throws < ObjectDisposedException > ( ( ) => pool . GetLooper ( ) ) ;
166+ Assert . Throws < ObjectDisposedException > ( ( ) => _ = pool . Loopers ) ;
167+ await Assert . ThrowsAsync < ObjectDisposedException > ( ( ) => pool . ShutdownAsync ( TimeSpan . Zero ) ) ;
168+
169+ pool . Dispose ( ) ;
170+ }
171+
144172 class FakeSequentialLogicLooperPoolBalancer : ILogicLooperPoolBalancer
145173 {
146174 private int _count ;
0 commit comments