Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2004, 01:10 PM
Authorized User
 
Join Date: May 2004
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post
Default Instancing Property Of VB Classes

The Instancing property controls how a COM component created in VB can be accessed by its clients. Two of the properties available for this property are:

    1) SingleUse
    2) MultiUse

Books state that with the Instancing property set to SingleUse, for every object that's created as a result of a client request, a new instance of the class is started. And if the Instancing property is set to MultiUse all the objects are created from a single instance of the class.

I am confused with this explanation. What does it mean to create multiple objects from a single class instance and to start a new instance of the class for each object that's created. Please give me a simple explanation of what exactly does it mean.

ejan
__________________
ejan
 
Old June 25th, 2004, 04:32 PM
tnd tnd is offline
Authorized User
 
Join Date: Jun 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You work on a PC. On your PC there are multiple process and threads running. If you know what process and thread are then skip to the next secion.

Process & Thread
Let's make a few pretends.

Your PC = Network of PCs
Process = Individual PCs on the network
Thread = Individual programs running on the PC

What this means is while you are using your PC (process), and you do know there are other PCs on the network but you really have no idea of exactly what programs (threads) the other PCs are runnning.

On your PC, you are running Word (thread) and Excel (thread). You need to share some data between them. Very easy, you can just copy and paste because it is on the same PC (process). So this means within a process, a thread gets to share the resources owned by the thread.

Say you need to shared your Word document with a co-worker on another PC. You must save the doc on the network and have the co-worker open the doc. In terms of process/threads, this means process cannot communicate directly with each other. Instead it must marshal the information across process boundries which is obviously alot more complicated then sharing data across threads.

Now to your question about single/multi-use

Singleuse object always gets its own process space whenever you create a new object.

Multiuse objects can be multi-threaded, that is whenever you create a new multiuse object, you are simply getting another thread from the same process.





 
Old July 18th, 2004, 03:15 PM
Registered User
 
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nice explanation tnd. One further point for ejan: This setting is only relevant for ActiveX Exe's (not dll's). Dlls are always created in the process space of the app/component that creates them.

MultiUse objects are all created by the ActiveX Exe server in the same thread, whereas the ActiveX Exe server creates each new single use object in separate thread

Single Use objects are great for when you have a complex hierarchy/oject model and you want the server to create a new set of them each time a new top level object is created (something like the Application object in Excel is a good example).

a:





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Classes in VB.net pwalkins ASP.NET 2.0 Basics 1 October 6th, 2008 01:59 PM
Help with Partial classes: C# -> VB.NET Antilles128 BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2 1 December 23rd, 2007 12:52 AM
classes for retriving MAC address in VB .NET mistrypremal Pro VB.NET 2002/2003 9 August 10th, 2007 12:12 PM
What is Meant by Instancing in Class Modules ramk_1978 VB Components 1 February 2nd, 2005 12:09 AM
The Instancing Property of VB Classes ejan VB Components 1 June 25th, 2004 04:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.