COMments

[Previous] [Next]

In a multithread process, COM objects can potentially reside in different apartments. (Refer to Chapter 3 for in-depth coverage of COM threading apartment models.) A side benefit of implementing the Object Factory design pattern in Visual Basic is that it is a means by which to dictate in what apartment a COM object will reside. This has significant performance implications. An object factory that uses the keyword New will create objects in the same apartment in which the object factory resides.

COM objects can also reside in server processes external to the client process. Therefore keep in mind that an initial request from a client to create an object would require two remote calls: one to reference a Factory instance and another to create the desired object. However, if a client intends to create multiple instances of a class, it should then hold on to the Factory reference to avoid the performance hit of an extra unnecessary remote call.



Microsoft Visual Basic Design Patterns
Microsoft Visual Basic Design Patterns (Microsoft Professional Series)
ISBN: B00006L567
EAN: N/A
Year: 2000
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net