15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Automation Server in other threads?

Mike Ward -- mikew@hilgraeve.com
Tuesday, September 10, 1996

Environment: VC++4.2, Win95

I've written an application that exposes an automation API using the
standard MFC/OLE mechanisms.  It functions fine as an out-of-proc
server.  However, all API requests happen in the context of the main
thread.  I would like to service the automation API requests in the
context of another thread.  I've tried several options.  Since the
automation API I've exposed is a CCmdTarget derived class, my first
thought was to instantiate an instance in another thread and the
build the requested DISPATCH pointer in the new thread context. 
Didn't work.  I also looked at writing a custom marshaller but could
not convince myself that it was the right solution.  My thought here
is that the underlying RPC mechanism needs to be told to service the
incoming requests from another thread context.  Sadly, I don't know
enough about OLE at this level, or MFC's implementation for that
matter to affect a solution.  Does anyone have thoughts, ideas,
solutions to this problem?  I can't imagine I'm the first person to
ever want to process server requests in other thread contexts. 



Mike Blaszczak -- mikeblas@nwlink.com
Tuesday, September 10, 1996

At 07:44 AM 9/10/96 -500, you wrote:
>Environment: VC++4.2, Win95

>I've written an application that exposes an automation API using the
>standard MFC/OLE mechanisms.  It functions fine as an out-of-proc
>server.  However, all API requests happen in the context of the main
>thread.  I would like to service the automation API requests in the
>context of another thread.  I've tried several options.  Since the
>automation API I've exposed is a CCmdTarget derived class, my first
>thought was to instantiate an instance in another thread and the
>build the requested DISPATCH pointer in the new thread context. 
>Didn't work. 

Read up on Apartment Model threading on the MSDN.  OLE supplies several
different threading models.  You'll need to either carefully subscribe
to one or implement your server to conform to the free-threaded model.

The models are detailed carefully in the SDK documentation, available
in the MSDN subscription.  The overviews in the MSDN developer library
can get you started.

.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |