@@ -6,7 +6,9 @@ public class AmqpNotOpenException(string message) : Exception(message);
66
77public abstract class AbstractLifeCycle : ILifeCycle
88{
9- protected virtual Task OpenAsync ( )
9+ private bool _disposedValue ;
10+
11+ public virtual Task OpenAsync ( )
1012 {
1113 OnNewStatus ( State . Open , null ) ;
1214 return Task . CompletedTask ;
@@ -16,6 +18,15 @@ protected virtual Task OpenAsync()
1618
1719 public State State { get ; internal set ; } = State . Closed ;
1820
21+ public event LifeCycleCallBack ? ChangeState ;
22+
23+ public void Dispose ( )
24+ {
25+ // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
26+ Dispose ( disposing : true ) ;
27+ GC . SuppressFinalize ( this ) ;
28+ }
29+
1930 protected void ThrowIfClosed ( )
2031 {
2132 switch ( State )
@@ -49,7 +60,27 @@ protected void OnNewStatus(State newState, Error? error)
4960 ChangeState ? . Invoke ( this , oldStatus , newState , error ) ;
5061 }
5162
52- public event LifeCycleCallBack ? ChangeState ;
63+ protected virtual void Dispose ( bool disposing )
64+ {
65+ if ( ! _disposedValue )
66+ {
67+ if ( disposing )
68+ {
69+ // TODO: dispose managed state (managed objects)
70+ }
71+
72+ // TODO: free unmanaged resources (unmanaged objects) and override finalizer
73+ // TODO: set large fields to null
74+ _disposedValue = true ;
75+ }
76+ }
77+
78+ // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
79+ // ~AbstractLifeCycle()
80+ // {
81+ // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
82+ // Dispose(disposing: false);
83+ // }
5384}
5485
5586public abstract class AbstractReconnectLifeCycle : AbstractLifeCycle
@@ -61,7 +92,7 @@ internal void ChangeStatus(State newState, Error? error)
6192 OnNewStatus ( newState , error ) ;
6293 }
6394
64- internal async Task Reconnect ( )
95+ internal async Task ReconnectAsync ( )
6596 {
6697 try
6798 {
@@ -84,7 +115,7 @@ internal async Task Reconnect()
84115 await Task . Delay ( delay ) . ConfigureAwait ( false ) ;
85116 if ( _backOffDelayPolicy . IsActive ( ) )
86117 {
87- await Reconnect ( ) . ConfigureAwait ( false ) ;
118+ await ReconnectAsync ( ) . ConfigureAwait ( false ) ;
88119 }
89120 }
90121 }
0 commit comments