CancelOperationRequest.CancelOperationAsync Method ()
Asynchronously requests to cancel the operation.
Namespace: Microsoft.WindowsServerSolutions.Storage
Assembly: StorageOM (in StorageOM.dll)
Syntax
public void CancelOperationAsync()
public:
void CancelOperationAsync()
Public Sub CancelOperationAsync
Examples
The following code example shows how to asynchronously request the cancellation of a disk repair operation:
try
{
StorageManager storageManager = new StorageManager();
storageManager.Connect();
}
catch (StorageObjectModelException stoEx)
{
//Handle exception
}
DiskSet diskSet = storageManager.DiskSets.FirstOrDefault(currDiskSet =>
currDiskSet.CurrentStatus == DiskSetStatus.Repairing);
if (diskSet == null)
{
Console.WriteLine("No diskset in repairing state found");
}
else
{
CancelOperationRequest cancelOperationRequest = diskSet.GetCancelRepairRequest();
try
{
cancelOperationRequest.PropertyChanged +=
cancelOperationRequest_PropertyChanged;
cancelOperationRequest.CancelOperationAsync();
}
catch (StorageObjectModelException stoEx)
{
Console.WriteLine("Exception: {0}. Error Code: {1}",
stoEx.Message, stoEx.ErrorCode);
}
}
The following code example shows the request delegate method:
private void cancelOperationRequest_PropertyChanged(
object obj, PropertyChangedEventArgs args)
{
CancelOperationRequest cancelOperationRequest =
(CancelOperationRequest)obj;
if(cancelOperationRequest.Status == OperationStatus.Succeeded)
{
Console.WriteLine("Request completed successfully");
}
else if (cancelOperationRequest.Status == OperationStatus.Failed)
{
Console.WriteLine("Request failed: {0}. Error Code: {1}",
cancelOperationRequest.ErrorMessage,
cancelOperationRequest.ErrorCode);
}
}
See Also
StorageManager
CancelOperationRequest Class
Microsoft.WindowsServerSolutions.Storage Namespace
Return to top