Compartilhar via


Threading and Notifications

In the case of free-threaded rowset objects, IConnectionPoint should be enabled to handle apartment-model or single-thread listeners. Single-threaded listeners should always be called on their thread so that the listeners are not unduly interrupted from the wrong thread.

The creator of a rowset must use CoMarshalInterface when making the object's interfaces available to other threads. Because these are free-threaded rowsets, COM will stay out of the way. If IConnectionPoint receives an interface from IRowsetNotify and it wants to use that interface on another thread, it must also use CoMarshalInterface to move the interface to another thread. Whatever moves the interface to another thread must call CoMarshalInterface. The receiving thread doesn't just get the pointer but becomes involved by extracting the pointer through CoUnmarshalInterface.

This entails a rowset that is written internally to use multiple threads, not just to run on multiple threads. Consequently, a rowset should keep track of the threads on which a listener is connected to it.

Multiple threads