Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Asynchronously sends the request for check disk to be run.
Namespace: Microsoft.WindowsServerSolutions.Storage
Assembly: StorageOM (in StorageOM.dll)
Syntax
public void CheckDiskAsync()
public:
void CheckDiskAsync()
Public Sub CheckDiskAsync
Examples
The following code example shows how to asynchronously request the check disk operation to be run:
try
{
StorageManager storageManager = new StorageManager();
storageManager.Connect();
}
catch (StorageObjectModelException stoEx)
{
//Handle exception
}
DiskSet diskSet = storageManager.DefaultDiskSet;
Boolean scanOnly = true;
if (diskSet == null)
{
Console.WriteLine("A default diskset was not found");
}
else
{
Volume volumeToCheck = diskSet.Volumes.FirstOrDefault();
if (volumeToCheck == null)
{
Console.WriteLine("Volume was not found");
}
else
{
CheckDiskRequest checkDiskRequest =
volumeToCheck.GetCheckDiskRequest(scanOnly);
try
{
checkDiskRequest.PropertyChanged += checkDiskRequest_PropertyChanged;
checkDiskRequest.Progress.PropertyChanged += Progress_PropertyChanged;
checkDiskRequest.CheckDiskAsync();
}
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 checkDiskRequest_PropertyChanged(
object obj, PropertyChangedEventArgs args)
{
CheckDiskRequest checkDiskRequest = (CheckDiskRequest)obj;
if(checkDiskRequest.Status == OperationStatus.Succeeded)
{
Console.WriteLine("Output Log: {0}", checkDiskRequest.OutputLog);
Console.WriteLine("Operation result: {0}", checkDiskRequest.Result);
}
else if (checkDiskRequest.Status == OperationStatus.Failed)
{
Console.WriteLine("Request failed: {0}. Error Code: {1}",
checkDiskRequest.ErrorMessage,
checkDiskRequest.ErrorCode);
}
}
The following code example shows the progress delegate method:
private void Progress_PropertyChanged(
object obj, PropertyChangedEventArgs args)
{
CheckDiskStepStatus checkDiskProgress = (CheckDiskStepStatus)obj;
Console.WriteLine("Progress Stage = {0}, Percent Complete = {1}",
checkDiskProgress.Step, checkDiskProgress.PercentComplete);
}
See Also
CheckDiskRequest Class
Microsoft.WindowsServerSolutions.Storage Namespace
Return to top