/// <summary>Performs execution of the command.</summary> protected override void ProcessRecord() { ((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Signal(Microsoft.Azure.AzConfig.Runtime.Events.CmdletProcessRecordStart).Wait(); if (((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Token.IsCancellationRequested) { return; } __processRecordId = System.Guid.NewGuid().ToString(); try { // work if (ShouldProcess($"Call remote 'Operations_CheckNameAvailability' operation")) { using (var asyncCommandRuntime = new Microsoft.Azure.AzConfig.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Token)) { asyncCommandRuntime.Wait(ProcessRecordAsync(), ((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Token); } } } catch (System.AggregateException aggregateException) { // unroll the inner exceptions to get the root cause foreach (var innerException in aggregateException.Flatten().InnerExceptions) { ((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Signal(Microsoft.Azure.AzConfig.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if (((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Token.IsCancellationRequested) { return; } // Write exception out to error channel. WriteError(new System.Management.Automation.ErrorRecord(innerException, string.Empty, System.Management.Automation.ErrorCategory.NotSpecified, null)); } } catch (System.Exception exception) { ((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Signal(Microsoft.Azure.AzConfig.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if (((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Token.IsCancellationRequested) { return; } // Write exception out to error channel. WriteError(new System.Management.Automation.ErrorRecord(exception, string.Empty, System.Management.Automation.ErrorCategory.NotSpecified, null)); } finally { ((Microsoft.Azure.AzConfig.Runtime.IEventListener) this).Signal(Microsoft.Azure.AzConfig.Runtime.Events.CmdletProcessRecordEnd).Wait(); } }