Partager via


CancelOperationRequest.CancelOperation Method ()

 

Sends the request to cancel the operation and wait for it to finish.

Namespace:   Microsoft.WindowsServerSolutions.Storage
Assembly:  StorageOM (in StorageOM.dll)

Syntax

public void CancelOperation()
public:
void CancelOperation()
Public Sub CancelOperation

Examples

The following code example shows how to 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.CancelOperation();
   }
   catch (StorageObjectModelException stoEx)
   {
      Console.WriteLine("Exception: {0}. Error Code: {1}", 
         stoEx.Message, stoEx.ErrorCode);
   }
}

See Also

StorageManager
CancelOperationRequest Class
Microsoft.WindowsServerSolutions.Storage Namespace

Return to top