Multi-threaded OLE Server Design.
FIGNET05.DARRINS@eds.com Tuesday, March 11, 1997 Environment: VC++ 4.2b, NT 4.0 I need some help in designing a multi-threaded OLE server application. I have a client that can talk to such a beast coded up and working with the single threaded version of the server, but I now need to make it multi-threaded as well. My client thread contacts the OLE server with the following: IData m_Data; OleInitialize(NULL); VERIFY(m_Data.CreateDispatch("OleServer.Data")==TRUE); strOutBound=m_Data.ProcessData("TESTING"); m_Data.ReleaseDispatch(); OleUninitialize(); What I want to have happen, is each time the client calls ProcessData(), a new thread gets fired off that will do some processing and return the result to the client. What I don't understand is how to kick off multiple threads in my OLE server so that they respond to the correct calling thread in the client. So should ProcessData() in the OLE server kick off a thread, or should I have a thread which creates and object of class IData (the class containing ProcessData())? If I do the latter, how do I tell ProcessData() who to respond to on the client side? BTW, are there any books that deal with OLE and threading? Inside OLE 2 didn't seem to have much on this subject. Thanks. Darrin
R.A.Ormesher -Richard Ormesher -- R.A.Ormesher@open.ac.uk Tuesday, March 18, 1997 [Mini-digest: 2 responses] You may find some useful info on multi-threading and COM in chapter 12 of Dale Rogerson's 'Inside COM' and there's an article by David Platt in MSJ, Mar 97. Richard > >Environment: VC++ 4.2b, NT 4.0 > >I need some help in designing a multi-threaded OLE server application. I >have a client that can talk to such a beast coded up and working with the >single threaded version of the server, but I now need to make it >multi-threaded as well. > >My client thread contacts the OLE server with the following: > > IData m_Data; > > OleInitialize(NULL); > > VERIFY(m_Data.CreateDispatch("OleServer.Data")==TRUE); > > strOutBound=m_Data.ProcessData("TESTING"); > > m_Data.ReleaseDispatch(); > > OleUninitialize(); > >What I want to have happen, is each time the client calls ProcessData(), >a new thread gets fired off that will do some processing and return the >result to the client. What I don't understand is how to kick off >multiple threads in my OLE server so that they respond to the correct >calling thread in the client. So should ProcessData() in the OLE server >kick off a thread, or should I have a thread which creates and object of >class IData (the class containing ProcessData())? If I do the latter, >how do I tell ProcessData() who to respond to on the client side? > >BTW, are there any books that deal with OLE and threading? Inside OLE 2 >didn't seem to have much on this subject. > >Thanks. > >Darrin > > -----From: David RazzettiHi Darrin -=20 I don't think that its worth my while to try and explain the intricacies of OLE and threading here. I suggest that you go and read the following articles: i. Give ActiveX-based Web Pages A Boost with the Apartment Threading Model - David Platt - MSJ March 1997. This article deals specifically with ActiveX controls on Web pages, but the description of the ApartmentThreading model and the examples are relevant to all types of server. ii. Q&A ActiveX/COM - Don Box - MSJ Jan/Feb 1997. This article deals with correctly maintaining the lifetime of multithreading servers. iii. Introducing Distributed COM and the New OLE Features in Windows NT 4.0 - Don Box - MSJ May 1996. Look at the section on Threading and More Threading for a good description of the Apartment model and the new FreeThreading model and how they work. iv. OLE Q&A - Don Box - MSJ April 1996. This article gives an indepth description of Apartment Threading and gives an excellent example of a multiple threaded server using the Apartment model. The first two of these articles have not yet appeared on the MSDN CD, but the last two are present on the CD. After you've read these articles, I recon you'll know enough to be able to put together some specific questions. Hope this helps Dave Razzetti raz@jump-jet.demon.co.uk On Tue, 11 Mar 1997 21:39:24 -0500, you wrote: >Environment: VC++ 4.2b, NT 4.0 > >I need some help in designing a multi-threaded OLE server application. = I >have a client that can talk to such a beast coded up and working with = the >single threaded version of the server, but I now need to make it >multi-threaded as well. > >My client thread contacts the OLE server with the following: > > IData m_Data; > OleInitialize(NULL); > VERIFY(m_Data.CreateDispatch("OleServer.Data")=3D=3DTRUE); > strOutBound=3Dm_Data.ProcessData("TESTING"); > m_Data.ReleaseDispatch(); > OleUninitialize(); > >What I want to have happen, is each time the client calls ProcessData(), >a new thread gets fired off that will do some processing and return the >result to the client. What I don't understand is how to kick off >multiple threads in my OLE server so that they respond to the correct >calling thread in the client. So should ProcessData() in the OLE server >kick off a thread, or should I have a thread which creates and object of >class IData (the class containing ProcessData())? If I do the latter, >how do I tell ProcessData() who to respond to on the client side? > >BTW, are there any books that deal with OLE and threading? Inside OLE 2 >didn't seem to have much on this subject. > >Thanks. > >Darrin >
Become an MFC-L member | Вернуться в корень Архива |