@@ -38,7 +38,7 @@ public override async Task OpenAsync()
3838
3939 Attach attach = Utils . CreateAttach ( _address , DeliveryMode . AtLeastOnce , _id ) ;
4040
41- void onAttached ( ILink argLink , Attach argAttach )
41+ void OnAttached ( ILink argLink , Attach argAttach )
4242 {
4343 if ( argLink is SenderLink link )
4444 {
@@ -53,24 +53,16 @@ void onAttached(ILink argLink, Attach argAttach)
5353 }
5454 }
5555
56- SenderLink ? tmpSenderLink = null ;
57- Task senderLinkTask = Task . Run ( async ( ) =>
58- {
59- Session session = await _connection . _nativePubSubSessions . GetOrCreateSessionAsync ( )
60- . ConfigureAwait ( false ) ;
61- tmpSenderLink = new SenderLink ( session , _id . ToString ( ) , attach , onAttached ) ;
62- } ) ;
56+ Session session = await _connection . _nativePubSubSessions . GetOrCreateSessionAsync ( )
57+ . ConfigureAwait ( false ) ;
58+ var tmpSenderLink = new SenderLink ( session , _id . ToString ( ) , attach , OnAttached ) ;
6359
6460 // TODO configurable timeout
65- TimeSpan waitSpan = TimeSpan . FromSeconds ( 5 ) ;
66-
61+ var waitSpan = TimeSpan . FromSeconds ( 5 ) ;
6762 _senderLink = await attachCompletedTcs . Task . WaitAsync ( waitSpan )
6863 . ConfigureAwait ( false ) ;
6964
70- await senderLinkTask . WaitAsync ( waitSpan )
71- . ConfigureAwait ( false ) ;
72-
73- System . Diagnostics . Debug . Assert ( tmpSenderLink != null ) ;
65+ // TODO this assertion may not be valid
7466 System . Diagnostics . Debug . Assert ( Object . ReferenceEquals ( _senderLink , tmpSenderLink ) ) ;
7567
7668 if ( _senderLink is null )
@@ -125,8 +117,10 @@ public async Task<PublishResult> PublishAsync(IMessage message, CancellationToke
125117
126118 void OutcomeCallback ( ILink sender , Message inMessage , Outcome outcome , object state )
127119 {
128- System . Diagnostics . Debug . Assert ( object . ReferenceEquals ( this , state ) ) ;
129- System . Diagnostics . Debug . Assert ( object . ReferenceEquals ( _senderLink , sender ) ) ;
120+ System . Diagnostics . Debug . Assert ( Object . ReferenceEquals ( this , state ) ) ;
121+
122+ // TODO this assertion may not be valid
123+ System . Diagnostics . Debug . Assert ( Object . ReferenceEquals ( _senderLink , sender ) ) ;
130124 // Note: sometimes `message` is null 🤔
131125 // System.Diagnostics.Debug.Assert(Object.ReferenceEquals(nativeMessage, message));
132126
0 commit comments