IVMTask::WaitForCompletion method
The WaitForCompletion method waits for the task to complete or until the specified timeout expires.
Syntax
HRESULT WaitForCompletion(
[in] long timeout
);
Parameters
-
timeout [in]
-
Specifies the time in milliseconds that this method will wait for the task completion before returning control to the caller. A value of -1 specifies that method will wait until the task completes without timing out. Other valid timeout values range from 0 to 4,000,000 milliseconds.
Return value
This method can return one of these values.
Return code | Description |
---|---|
|
The operation was successful. |
|
The timeout parameter was outside its valid range of values. |
|
An unexpected error occurred. |
Remarks
The WaitForCompletion method puts the current execution thread to sleep until it returns. Specifying an infinite wait (timeout = -1) is not recommended unless it is absolutely critical that the task completes under any circumstance.
Examples
This example compacts a dynamic hard disk image using the specified timeout. It throws exceptions on any error back to the calling routine.
void CompactWithTimeout(IVMHardDIskPtr pIHD, long seconds){}
void CompactWithTimeout(IVMHardDiskPtr pIHD, long seconds) throw(/*...*/)
{
try
{
// Check calling arguments, do not allow an infinite wait
if (pIHD == NULL || seconds < 1)
{
throw _com_error(E_POINTER);
}
else
{
try
{
IVMTaskPtr pITask = pIHD->Compact(); // start HD compaction
pITask->WaitForCompletion(seconds*1000); // IVMTask timeout is in mSec
}
catch (/*...*/) {throw;}
}
}
// toss error back to caller
catch (/*...*/) {throw;}
}
Requirements
Product |
Microsoft Virtual Server 2005 onWindows Server 2003 |
Download |
Microsoft Virtual Server 2005 R2 SP1 Update onWindows Server 2008orWindows Server 2003 |
Header |
|