HrThisThreadAdviseSink 

The HrThisThreadAdviseSink function creates an advise sink that wraps an existing advise sink for thread safety.

Quick Info

Header file:

MAPIUTIL.H

Implemented by:

MAPI

Called by:

Client applications

 

HrThisThreadAdviseSink(

    LPMAPIADVISESINK lpAdviseSink,

 

    LPMAPIADVISESINK FAR * lppAdviseSink

 

   );

 

 

Parameters

lpAdviseSink

[in] Pointer to the advise sink to be wrapped.

lppAdviseSink

[out] Pointer to a pointer to a new advise sink that wraps the advise sink pointed to by the lpAdviseSink parameter.

 

Remarks

The purpose of the wrapper is to ensure that notification is called on the same thread that called the HrThisThreadAdviseSink function. This function is used to protect notification callbacks that must run on a particular thread.

Client applications should use HrThisThreadAdviseSink to restrict when notifications are generated. This happens when calls are made to the IMAPIAdviseSink::OnNotify5WYI5X method of the advise sink object passed by the client in a previous Advise call. If notifications can be generated arbitrarily, a notification implementation might make a client multithreaded when multithreading is inappropriate. For example, this result is troublesome when an implementation has been created using a library, such as one of the Microsoft Foundation Class Libraries, that does not support multithreaded calls. In this situation, a client is difficult to test and is prone to error.

HrThisThreadAdviseSink ensures that the OnNotify methods calls occur at these appropriate times:

    During the processing of any call to any MAPI method.

    When window messages are being processed.

 

When HrThisThreadAdviseSink is implemented, any calls to the new advise sink s OnNotify method on any thread cause the original notification method to be executed on the thread in which HrThisThreadAdviseSink was called.

For more information on notification and advise sinks, see Event Notification in MAPIE.8REW and Implementing an Advise Sink Object16PPQ8K.