public async Task CloseAsyncAndAbort_NotFailing() { ICommunicationListener listener = CreateListener(addresses: "https://localhost:80"); await listener.CloseAsync(CancellationToken.None); listener.Abort(); }
void ActivateServiceType(Type serviceType) { //DESIGN NOTE: //Use the first manifest for initialization. For all Fabric-based interactions, ServiceContext sent in message updates context. ApplicationManifestAttribute[] manifests = serviceType.GetCustomAttributes <ApplicationManifestAttribute>().ToArray(); StatelessServiceContext serviceContext = new StatelessServiceContext { ServiceName = new Uri("fabric:/" + manifests[0].ApplicationName + "/" + manifests[0].ServiceName) }; StatelessService service = Activator.CreateInstance(serviceType, serviceContext) as StatelessService; foreach (ServiceInstanceListener instanceListener in service.ServiceInstanceListeners) { ICommunicationListener listener = instanceListener.CreateCommunicationListener(serviceContext); if (listener is WcfCommunicationListener) { ActivateWcfService(serviceType, listener as WcfCommunicationListener); } else { listener.OpenAsync(new System.Threading.CancellationToken()).Wait(); AppDomain.CurrentDomain.ProcessExit += delegate { try { listener.CloseAsync(new System.Threading.CancellationToken()).Wait(); } catch {} }; } } }
private async Task _CloseListener( string ListenerName, ICommunicationListener listener, CancellationToken cancelToken) { this.statuses[ListenerName] = ICommunicationListenerStatus.Closing; await listener.CloseAsync(cancelToken); this.statuses[ListenerName] = ICommunicationListenerStatus.Closed; this.traceWriter.TraceMessage(string.Format("Composite listener - listener {0} closed", ListenerName)); }
private async Task _CloseListener( string ListenerName, ICommunicationListener listener, CancellationToken cancelToken) { this.statuses[ListenerName] = ICommunicationListenerStatus.Closing; await listener.CloseAsync(cancelToken); this.statuses[ListenerName] = ICommunicationListenerStatus.Closed; this.traceWriter.TraceMessage(string.Format("Composite listener - listener {0} closed", ListenerName)); }
/// <summary> /// This method causes the communication listener to close. Close is a terminal state and /// this method allows the communication listener to transition to this state in a /// graceful manner. /// </summary> /// <param name="cancellationToken">Cancellation token</param> /// <returns> /// A <see cref="T:System.Threading.Tasks.Task">Task</see> that represents outstanding operation. /// </returns> public Task CloseAsync(CancellationToken cancellationToken) { return(_wrappedCommunicationListener.CloseAsync(cancellationToken)); }
private async Task _CloseListener( ICommunicationListener listener, CancellationToken cancelToken) { await listener.CloseAsync(cancelToken); }
private async Task CloseListener( string listenerName, ICommunicationListener listener, CancellationToken cancelToken) { _statuses[listenerName] = CommunicationListenerStatus.Closing; await listener.CloseAsync(cancelToken); _statuses[listenerName] = CommunicationListenerStatus.Closed; }