IHolder::Close method
Closes the Holder.
Syntax
HRESULT Close();
Parameters
This method has no parameters.
Return value
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
This closes a Resource Dispenser's Holder, after which the Resource Dispenser probably released. Before closing, any remaining inventory is destroyed by calling back to the Resource Dispenser's IDispenserDriver::DestroyResource method.
The following sequence describes how to close down a Resource Dispenser:
- Obtain a reference to the Resource Dispenser (the object that exposes IDispenserDriver).
- Call a method in Resource Dispenser whose implementation calls IHolder::Close.
- IHolder::Close destroys any remaining inventory by calling back to Resource Dispenser's IDispenserDriver::DestroyResource method.
- IHolder::Close calls the Dispenser Manager to remove this Holder from the Holder list. (If no Holders remain, the Dispenser Manager object deletes itself.)
- IHolder::Close releases its reference to Resource Dispenser's IDispenserDriver interface. This is the reason you need a reference in step 1; otherwise, the Resource Dispenser would delete itself prematurely before the subsequent steps can be completed.
- IHolder::Close returns to the Resource Dispenser.
- The Resource Dispenser calls IDispenserDriver::DestroyResource. The Holder now deletes itself.
- The method called in step 2 now returns.
- Release your final reference to the Resource Dispenser, which now deletes itself.
Note that the IDispenserManager::RegisterDispenser method does not call AddRef on its pDispenserDriver object, but IHolder::Close does perform a Release on pDispenserDriver. This can cause the Resource Dispenser object to be destroyed prematurely. To prevent this premature destruction, the caller of IHolder::Close must hold a reference to the Resource Dispenser object as described in steps 1 and 5.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
See also