public async Task <string> OpenAsync(CancellationToken cancellationToken) { try { this.ValidateListeners(); this.listenerLock.WaitOne(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Opening; List <Task <KeyValuePair <string, string> > > tasks = new List <Task <KeyValuePair <string, string> > >(); Dictionary <string, string> addresses = new Dictionary <string, string>(); foreach (KeyValuePair <string, ICommunicationListener> kvp in this.listeners) { tasks.Add( Task.Run( async() => { string PublishAddress = await this._OpenListener(kvp.Key, kvp.Value, cancellationToken); return(new KeyValuePair <string, string> ( kvp.Key, PublishAddress )); })); } await Task.WhenAll(tasks); foreach (Task <KeyValuePair <string, string> > task in tasks) { addresses.Add(task.Result.Key, task.Result.Value); } this.EnsureFuncs(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Opened; return(String.Empty); } finally { this.listenerLock.Set(); } }
public void Abort() { try { this.listenerLock.WaitOne(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Aborting; foreach (KeyValuePair<string, ICommunicationListener> kvp in this.listeners) { this._AbortListener(kvp.Key, kvp.Value); } this.CompsiteListenerStatus = ICommunicationListenerStatus.Aborted; } finally { this.listenerLock.Set(); } }
public void Abort() { try { this.listenerLock.WaitOne(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Aborting; foreach (KeyValuePair <string, ICommunicationListener> kvp in this.listeners) { this._AbortListener(kvp.Key, kvp.Value); } this.CompsiteListenerStatus = ICommunicationListenerStatus.Aborted; } finally { this.listenerLock.Set(); } }
public async Task CloseAsync(CancellationToken cancellationToken) { try { this.listenerLock.WaitOne(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Closing; List<Task> tasks = new List<Task>(); foreach (KeyValuePair<string, ICommunicationListener> kvp in this.listeners) { tasks.Add(this._CloseListener(kvp.Key, kvp.Value, cancellationToken)); } await Task.WhenAll(tasks); this.CompsiteListenerStatus = ICommunicationListenerStatus.Closed; } finally { this.listenerLock.Set(); } }
public async Task CloseAsync(CancellationToken cancellationToken) { try { this.listenerLock.WaitOne(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Closing; List <Task> tasks = new List <Task>(); foreach (KeyValuePair <string, ICommunicationListener> kvp in this.listeners) { tasks.Add(this._CloseListener(kvp.Key, kvp.Value, cancellationToken)); } await Task.WhenAll(tasks); this.CompsiteListenerStatus = ICommunicationListenerStatus.Closed; } finally { this.listenerLock.Set(); } }
public async Task<string> OpenAsync(CancellationToken cancellationToken) { try { this.ValidateListeners(); this.listenerLock.WaitOne(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Opening; List<Task<KeyValuePair<string, string>>> tasks = new List<Task<KeyValuePair<string, string>>>(); Dictionary<string, string> addresses = new Dictionary<string, string>(); foreach (KeyValuePair<string, ICommunicationListener> kvp in this.listeners) { tasks.Add( Task.Run( async () => { string PublishAddress = await this._OpenListener(kvp.Key, kvp.Value, cancellationToken); return new KeyValuePair<string, string> ( kvp.Key, PublishAddress ); })); } await Task.WhenAll(tasks); foreach (Task<KeyValuePair<string, string>> task in tasks) { addresses.Add(task.Result.Key, task.Result.Value); } this.EnsureFuncs(); this.CompsiteListenerStatus = ICommunicationListenerStatus.Opened; return String.Empty; } finally { this.listenerLock.Set(); } }