Esempio n. 1
0
 public void Dispose()
 {
     lock (this._subscriptions)
     {
         if (this._subscriptions.Count != 0)
         {
             ISubscribable[] subscriptions = this._subscriptions.ToArray();
             this._subscriptions.Clear();
             Array.ForEach(subscriptions, subscription => this._dataService.UnsubscribeClient(this.SessionId, subscription));
         }
     }
     ServiceModelMethods.TryClose(this.CallbackContract);
 }
        private IServerContract InitializeChannel()
        {
            IServerContract      channel             = this._factory.CreateChannel();
            ICommunicationObject communicationObject = (ICommunicationObject)channel;

            try
            {
                communicationObject.Open();
            }
            catch
            {
                ServiceModelMethods.TryClose(channel);
                return(null);
            }
            communicationObject.Closed  += this.Channel_ClosedOrFaulted;
            communicationObject.Faulted += this.Channel_ClosedOrFaulted;
            return(channel);
        }
 public void Dispose()
 {
     if (this._isDisposed)
     {
         return;
     }
     this._isDisposed = true;
     this._resetEvent.Set();
     this._channelThread.Join();
     if (this._channel != null)
     {
         ICommunicationObject communicationObject = (ICommunicationObject)this._channel;
         communicationObject.Closed  -= this.Channel_ClosedOrFaulted;
         communicationObject.Faulted -= this.Channel_ClosedOrFaulted;
     }
     ServiceModelMethods.TryClose(Interlocked.Exchange(ref this._channel, null));
     ServiceModelMethods.TryClose(this._factory);
     using (this._heartbeatTimer)
     {
         this._heartbeatTimer.Change(Timeout.Infinite, Timeout.Infinite);
     }
 }