## CDeferredCommand Class

Deferred commands are queued by calls to methods on the IQueueCommand interface and are exposed by the filter graph manager and by some filters. A successful call to one of these methods returns an IDeferredCommand interface representing the queued command.

A CDeferredCommand object represents a single deferred command and exposes the IDeferredCommand interface as well as other methods that permit time checks and actual execution. A CDeferredCommand object contains a reference to the CCmdQueue object on which it is queued.

Reference counts control the lifetime of the CDeferredCommand class. When calling the CDeferredCommand::Invoke member function, the calling application gets an interface pointer that is reference-counted, and the CCmdQueue object also holds a reference count on the deferred command. Calling the IDeferredCommand::Cancel member function takes the deferred command off the command queue and thus reduces the reference count by one. Once taken off the queue, the command cannot be put back on the queue.

Protected Data Members

Name | Description
m_bStream | Flag for stream time or presentation time. to be passed to the invoked method.
m_Dispatch | Accesses the ITypeInfo interface.
m_dispidMethod | Method on the interface to run.
m_DispParams | CDispParams object containing the DISPPARAMS parameter list
m_hrResult | Stores the returned HRESULT value.
m_iid | Globally unique identifier (GUID) of the interface.
m_pQueue | Pointer to the CCmdQueue object that exposes the IQueueCommand interface.
m_pUnk | IUnknown pointer to the interface on which the command will be run.
m_pvarResult | Resulting information, if any, from the invoked method.
m_time | Time at which the command will be run.
m_wFlags | Flags specifying the context of the invocation.

Member Functions

Name | Description
CDeferredCommand | Constructs a CDeferredCommand object.
GetFlags | Returns the context flags associated with the deferred command.
GetIID | Returns the interface identifier (IID) of the interface on which the method will be run.
GetMethod | Returns the dispatch identifier of the method to be run.
GetParams | Returns the DISPPARAMS argument list to the method.
GetResult | Returns the resulting argument list, if one exists.
GetTime | Returns the time when the method will be run.
Invoke | Provides access to methods and properties exposed by an object.
IsStreamTime | Specifies whether the command is to be run at stream time or presentation time.

Implemented IDeferredCommand Methods

Name | Description
Cancel | Cancels a previously queued CDeferredCommand::Invoke request.
Confidence | Not currently implemented.
Postpone | Specifies a new presentation time for a previously queued command.
GetHResult | Returns the HRESULT value of the invoked method.

Implemented INonDelegatingUnknown Methods

Name | Description
NonDelegatingQueryInterface | Returns a specified reference-counted interface.

###

CDeferredCommand::Cancel

CDeferredCommand Class

Cancels a previously queued CDeferredCommand::Invoke request.

HRESULT Cancel( );

##### Return Values

Returns VFW_E_ALREADY_CANCELLED if m_pQueue is NULL. Returns an HRESULT from CCmdQueue::Remove if the call generates an error. Returns S_OK if successful.

##### Remarks

This member function implements the IDeferredCommand::Cancel method.

###

CDeferredCommand::CDeferredCommand

CDeferredCommand Class

Constructs a CDeferredCommand object.

CDeferredCommand(
CCmdQueue * pQ,
LPUNKNOWN pUnk,
HRESULT * phr,
LPUNKNOWN pUnkExecutor,
REFTIME time,
GUID* iid,
long dispidMethod,
short wFlags,
long cArgs,
VARIANT* pDispParams,
VARIANT* pvarResult,
short* puArgErr,
BOOL bStream
);

##### Parameters

pQ
  Object that exposes the IQueueCommand interface.
pUnk
  Outer IUnknown interface for aggregation.
phr
  Returning HRESULT value.
pUnkExecutor
  Object that will carry out this command.
time
  Time at which the command will be run.
iid
  Globally unique identifier (GUID) of the interface that contains the method.
dispidMethod
  Method on the interface to call.
wFlags
  Context of the invocation.
cArgs
  Number of arguments passed.
pDispParams
  List of argument variant types.
pvarResult
  Returned variant type list, if any.
puArgErr
  Last argument in the pDispParams parameter list with an error.
bStream
  TRUE if the deferred command time is in stream time; FALSE if in presentation time.

##### Return Values

No return value.

###

CDeferredCommand::Confidence

CDeferredCommand Class

This method is not currently implemented.

HRESULT Confidence(
LONG *pConfidence
);

##### Parameters

pConfidence
  Confidence level.

##### Return Values

Returns E_NOTIMPL.

##### Remarks

See IDeferredCommand::Confidence for information about implementing this method.

###

CDeferredCommand::GetFlags

CDeferredCommand Class

Returns the context flags associated with the deferred command.

short GetFlags( );

##### Return Values

The value retrieved will be one of the following.

Value | Description
DISPATCH_METHOD | Run the member as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag may be set.
DISPATCH_PROPERTYGET | The member is being retrieved as a property or data member.
DISPATCH_PROPERTYPUT | The member is being changed as a property or data member.
DISPATCH_PROPERTYPUTREF | The member is being changed via a reference assignment, rather than a value assignment. This flag is valid only when the property accepts a reference to an object.

###

CDeferredCommand::GetHResult

CDeferredCommand Class

Returns the HRESULT value from the invoked command.

HRESULT GetHResult(
HRESULT* phrResult
);

##### Parameters

phrResult
  HRESULT value.

##### Return Values

Returns E_ABORT if m_pQueue is NULL. Otherwise, returns S_OK.

##### Remarks

This member function implements the IDeferredCommand::GetHResult method.

###

CDeferredCommand::GetIID

CDeferredCommand Class

Retrieves the interface identifier (IID) of the interface on which the method will be run.

REFIID GetIID( );

###

CDeferredCommand::GetMethod

CDeferredCommand Class

Retrieves the dispatch identifier of the method to be run.

long GetMethod( );

###

CDeferredCommand::GetParams

CDeferredCommand Class

Retrieves the DISPPARAMS argument list to the method.

DISPPARAMS* GetParams( );

###

CDeferredCommand::GetResult

CDeferredCommand Class

Retrieves the resulting argument list, if one exists.

VARIANT* GetResult( );

###

CDeferredCommand::GetTime

CDeferredCommand Class

Returns the time at which the method will be run.

CRefTime GetTime( );

##### Return Values

Returns a CRefTime object containing a reference time.

###

CDeferredCommand::Invoke

CDeferredCommand Class

Provides access to methods and properties exposed by an object.

HRESULT Invoke( );

##### Return Values

Returns VFW_E_ALREADY_CANCELLED if m_pQueue is NULL. Otherwise, returns the HRESULT resulting from a call to IDispatch::GetTypeInfo or IUnknown::QueryInterface.

###

CDeferredCommand::IsStreamTime

CDeferredCommand Class

Specifies whether the command is to be run at stream time or presentation time.

BOOL IsStreamTime( );

##### Return Values

Returns TRUE if set to stream time; otherwise, returns FALSE.

###

CDeferredCommand::NonDelegatingQueryInterface

CDeferredCommand Class

Returns a specified reference-counted interface.

HRESULT NonDelegatingQueryInterface(
REFIID riid,
void **ppv
);

##### Parameters

riid
  Reference identifier.
ppv
  Pointer to the interface.

##### Return Values

Returns E_POINTER if ppv is invalid. Returns NOERROR if the query is successful or E_NOINTERFACE if it is not.

##### Remarks

Returns pointers to the IDeferredCommand and IUnknown interfaces by default. Override this method to publish any additional interfaces implemented by the derived class.

This member function implements the INonDelegatingUnknown::NonDelegatingQueryInterface method.

###

CDeferredCommand::Postpone

CDeferredCommand Class

Specifies a new presentation time for a previously queued command.

HRESULT Postpone(
REFTIME newtime
);

##### Parameters

newtime
  New presentation time.

##### Return Values

Returns VFW_E_TIME_ALREADY_PASSED if newtime is already passed. Otherwise, returns an HRESULT resulting from a call to CCmdQueue::Remove (when extracting from the list) or CCmdQueue::Insert (when reinserting with the changed time).

##### Remarks

This member function implements the IDeferredCommand::Postpone method.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.