/// <summary> /// <para>Deletes the specific Service Fabric container network.</para> /// </summary> /// <param name="deleteNetworkDescription"> /// <para>The description of the container network to be deleted.</para> /// <param name="timeout"> /// <para>Defines the maximum amount of time the system will allow this operation to continue before returning <see cref="System.TimeoutException" />.</para> /// </param> /// </param> /// <param name="cancellationToken"> /// <para>The CancellationToken that the operation is observing. It can be used to propagate notification that the operation should be canceled.</para> /// </param> /// <returns> /// <para>A <see cref="System.Threading.Tasks.Task" /> representing the operation.</para> /// </returns> public Task DeleteNetworkAsync(DeleteNetworkDescription deleteNetworkDescription, TimeSpan timeout, CancellationToken cancellationToken) { this.fabricClient.ThrowIfDisposed(); Requires.Argument <DeleteNetworkDescription>("deleteNetworkDescription", deleteNetworkDescription).NotNull(); DeleteNetworkDescription.Validate(deleteNetworkDescription); return(this.DeleteNetworkAsyncHelper(deleteNetworkDescription, timeout, cancellationToken)); }
private Task DeleteNetworkAsyncHelper(DeleteNetworkDescription deleteNetworkDescription, TimeSpan timeout, CancellationToken cancellationToken) { return(Utility.WrapNativeAsyncInvokeInMTA( (callback) => this.DeleteNetworkBeginWrapper(deleteNetworkDescription, timeout, callback), this.DeleteNetworkEndWrapper, cancellationToken, "NetworkManager.DeleteNetworkAsync")); }
protected override void ProcessRecord() { DeleteNetworkDescription deletenetworkDescription = new DeleteNetworkDescription(this.NetworkName); var cluster = this.GetClusterConnection(); try { this.WriteObject(StringResources.Info_DeletingServiceFabricNetwork); cluster.FabricClient.NetworkManager.DeleteNetworkAsync( deletenetworkDescription, this.GetTimeout(), this.GetCancellationToken()).Wait(); this.WriteObject(StringResources.Info_DeleteServiceFabricNetworkSucceeded); } catch (AggregateException aggregateException) { this.WriteObject(StringResources.Error_DeleteServiceFabricNetworkFailed); aggregateException.Handle((ae) => { this.ThrowTerminatingError( ae, Constants.GetNetworkErrorId, null); return(true); }); } catch (Exception exception) { this.WriteObject(StringResources.Error_DeleteServiceFabricNetworkFailed); this.WriteObject(exception.ToString()); this.ThrowTerminatingError( exception, Constants.NewNetworkConfigurationErrorId, null); } }
private NativeCommon.IFabricAsyncOperationContext DeleteNetworkBeginWrapper(DeleteNetworkDescription deleteNetworkDescription, TimeSpan timeout, NativeCommon.IFabricAsyncOperationCallback callback) { using (var pin = new PinCollection()) { return(this.nativeNetworkManagementClient.BeginDeleteNetwork( deleteNetworkDescription.ToNative(pin), Utility.ToMilliseconds(timeout, "timeout"), callback)); } }
/// <summary> /// <para>Deletes the specific Service Fabric container network.</para> /// </summary> /// <param name="deleteNetworkDescription"> /// <para>The description of the container network to be deleted.</para> /// </param> /// <returns> /// <para>A <see cref="System.Threading.Tasks.Task" /> representing the operation.</para> /// </returns> public Task DeleteNetworkAsync(DeleteNetworkDescription deleteNetworkDescription) { return(this.DeleteNetworkAsync(deleteNetworkDescription, FabricClient.DefaultTimeout, CancellationToken.None)); }