Esempio n. 1
0
        protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
        {
            bool startAnnouncements = false;

            this.asyncOpenTimeoutHelper = new TimeoutHelper(timeout);
            this.asyncOpenTimeoutHelper.RemainingTime();
            this.announceOnlineAsyncResult = new AnnouncementDispatcherAsyncResult(this.announcementEndpoints, this.publishedEndpoints, this.discoveryMessageSequenceGenerator, true, callback, state);
            lock (this.thisLock)
            {
                if (this.dispatchersToWait == 0)
                {
                    startAnnouncements = true;
                    this.dispatchersToWait--;
                }
            }
            if (this.State != CommunicationState.Opening)
            {
                // Fixes the ---- when OnAbort is called after OnBeginOpen but before this.announceOnlineAsyncResult is created
                this.announceOnlineAsyncResult.Cancel();
            }
            else if (startAnnouncements)
            {
                this.announceOnlineAsyncResult.Start(this.asyncOpenTimeoutHelper.RemainingTime(), true);
            }
            return(this.announceOnlineAsyncResult);
        }
 protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
 {
     this.announceOfflineAsyncResult = new AnnouncementDispatcherAsyncResult(this.announcementEndpoints, this.publishedEndpoints, this.discoveryMessageSequenceGenerator, false, callback, state);
     if (this.abortAnnouncement)
     {
         // Fixes the ---- when OnAbort is called after OnBeginClose but before this.announceOnlineAsyncResult is created
         this.announceOfflineAsyncResult.Cancel();
     }
     else
     {
         this.announceOfflineAsyncResult.Start(timeout, true);
     }
     return(this.announceOfflineAsyncResult);
 }
Esempio n. 3
0
 protected override void OnOpen(TimeSpan timeout)
 {
     this.announceOnlineAsyncResult = new AnnouncementDispatcherAsyncResult(this.announcementEndpoints, this.publishedEndpoints, this.discoveryMessageSequenceGenerator, true, null, null);
     if (this.State != CommunicationState.Opening)
     {
         // Fixes the ---- when OnAbort is called after OnOpen but before this.announceOnlineAsyncResult is created
         this.announceOnlineAsyncResult.Cancel();
     }
     else
     {
         this.announceOnlineAsyncResult.Start(timeout, true);
     }
     AnnouncementDispatcherAsyncResult.End(this.announceOnlineAsyncResult);
 }
 protected override void OnOpen(TimeSpan timeout)
 {
     this.announceOnlineAsyncResult = new AnnouncementDispatcherAsyncResult(this.announcementEndpoints, this.publishedEndpoints, this.discoveryMessageSequenceGenerator, true, null, null);
     if (this.State != CommunicationState.Opening)
     {
         // Fixes the ---- when OnAbort is called after OnOpen but before this.announceOnlineAsyncResult is created
         this.announceOnlineAsyncResult.Cancel();
     }
     else
     {
         this.announceOnlineAsyncResult.Start(timeout, true);
     }
     AnnouncementDispatcherAsyncResult.End(this.announceOnlineAsyncResult);
 }
 protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
 {
     bool startAnnouncements = false;
     this.asyncOpenTimeoutHelper = new TimeoutHelper(timeout);
     this.asyncOpenTimeoutHelper.RemainingTime();
     this.announceOnlineAsyncResult = new AnnouncementDispatcherAsyncResult(this.announcementEndpoints, this.publishedEndpoints, this.discoveryMessageSequenceGenerator, true, callback, state);
     lock (this.thisLock)
     {
         if (this.dispatchersToWait == 0)
         {
             startAnnouncements = true;
             this.dispatchersToWait--;
         }
     }
     if (this.State != CommunicationState.Opening)
     {
         // Fixes the ---- when OnAbort is called after OnBeginOpen but before this.announceOnlineAsyncResult is created
         this.announceOnlineAsyncResult.Cancel();
     }
     else if (startAnnouncements)
     {
         this.announceOnlineAsyncResult.Start(this.asyncOpenTimeoutHelper.RemainingTime(), true);
     }
     return this.announceOnlineAsyncResult;
 }
 protected override void OnEndClose(IAsyncResult result)
 {
     AnnouncementDispatcherAsyncResult.End(result);
 }