コード例 #1
0
 public CloseAsyncResult(TimeSpan timeout, AsyncCallback callback, object state, ServiceHostBase serviceHost) : base(callback, state)
 {
     this.timeoutHelper = new TimeoutHelper(timeout);
     this.serviceHost   = serviceHost;
     if (ManagementExtension.IsEnabled && (serviceHost.Description != null))
     {
         ManagementExtension.OnServiceClosing(serviceHost);
     }
     this.CloseListeners(true);
 }
コード例 #2
0
 protected override void OnClose(TimeSpan timeout)
 {
     try
     {
         TimeoutHelper helper = new TimeoutHelper(timeout);
         if (ManagementExtension.IsEnabled && (this.Description != null))
         {
             ManagementExtension.OnServiceClosing(this);
         }
         for (int i = 0; i < this.ChannelDispatchers.Count; i++)
         {
             ChannelDispatcherBase base2 = this.ChannelDispatchers[i];
             if (base2.Listener != null)
             {
                 base2.Listener.Close(helper.RemainingTime());
             }
         }
         for (int j = 0; j < this.ChannelDispatchers.Count; j++)
         {
             this.ChannelDispatchers[j].CloseInput(helper.RemainingTime());
         }
         this.instances.CloseInput(helper.RemainingTime());
         this.instances.Close(helper.RemainingTime());
         for (int k = 0; k < this.ChannelDispatchers.Count; k++)
         {
             this.ChannelDispatchers[k].Close(helper.RemainingTime());
         }
         this.TraceBaseAddresses();
         ThreadTrace.StopTracing();
     }
     catch (TimeoutException exception)
     {
         if (DiagnosticUtility.ShouldTraceWarning)
         {
             TraceUtility.TraceEvent(TraceEventType.Warning, 0x8002e, System.ServiceModel.SR.GetString("TraceCodeServiceHostTimeoutOnClose"), this, exception);
         }
         base.Abort();
     }
 }