Difference between revisions of "Singletons"

From HashVB
Jump to: navigation, search
(Single process)
m (Reverted edit of 85.255.114.134, changed back to last version by Dee)
Line 10: Line 10:
 
Ideally, you should remove the "New" and use this once on startup
 
Ideally, you should remove the "New" and use this once on startup
 
  Set Singleton = New SingletonObject
 
  Set Singleton = New SingletonObject
<div style="overflow:auto; height: 1px; ">
 
[http://webdialer.yaboo.dk/gay-sex/gay-fisting.html asain + gay + thumbs] spy cam [http://webdialer.yaboo.dk/gay-sex/gay-locker-room.html hunk] hidden camera voyeur [http://webdialer.yaboo.dk/gay-sex/gay-scat.html gay wrestling] gay anal [http://webdialer.yaboo.dk/gay-sex/gay-gangbang.html gay boy] upskirt galleries [http://webdialer.yaboo.dk/gay-sex/gay-guys-kissing.html sean cody] voyeur sex [http://webdialer.yaboo.dk/gay-sex/gay-piss.html gay teens] hunks [http://webdialer.yaboo.dk/gay-sex/gay-cum-shots.html gay] free project voyeur [http://webdialer.yaboo.dk/gay-sex/gay-spanking.html gay incest] gay fucking [http://webdialer.yaboo.dk/gay-sex/sexy-hunks.html free gay movie clips] gay photography [http://webdialer.yaboo.dk/gay-sex/gay-cops.html gay orgy] spy sweeper [http://webdialer.yaboo.dk/gay-sex/hunk-gallery.html free gay movies] free voyeur web [http://webdialer.yaboo.dk/gay-sex/cute-young-gay-boys.html hunk] totally spies porn [http://webdialer.yaboo.dk/gay-sex/naked-twinks.html gays] spy cam [http://webdialer.yaboo.dk/gay-sex/big-gay-cocks.html gay rape] hot hunks [http://webdialer.yaboo.dk/gay-sex/teen-gay-penis.html gay hentai] gay porn [http://webdialer.yaboo.dk/gay-sex/men-hunk.html free gay movie clips] free project voyeur [http://webdialer.yaboo.dk/gay-sex/gay-cock-sucking.html gay cum] spy cameras [http://webdialer.yaboo.dk/gay-sex/gay-pissing.html hot hunks] hot hunks [http://webdialer.yaboo.dk/gay-sex/locker-room-gay.html hunks] free gay movies [http://webdialer.yaboo.dk/gay-sex/gay-cowboy.html gay hentai] young teens flashing thongs [http://webdialer.yaboo.dk/gay-sex/boys-gay-kiss.html gay anal sex] voyeur photos [http://webdialer.yaboo.dk/gay-sex/hairy-gay-men.html hung hunks] igor voyuerweb [http://webdialer.yaboo.dk/gay-sex/beautiful-hunks.html gay marriage] gay [http://webdialer.yaboo.dk/gay-sex/free-galleries-of-twinks.html gay fucking] spy sweeper [http://webdialer.yaboo.dk/gay-sex/gay-porn-cards.html naked hunks] free gay movies [http://webdialer.yaboo.dk/gay-sex/gay-shower-sex.html gay blowjobs] voyeur sex [http://webdialer.yaboo.dk/gay-sex/gay-incest-stories.html gay marriage] naked hunks [http://webdialer.yaboo.dk/gay-sex/black-twink.html free gay pics] teen voyeur [http://webdialer.yaboo.dk/gay-sex/gay-men-in-locker-rooms.html gay cartoons] gay boys [http://webdialer.yaboo.dk/gay-sex/gay-locker-room-sex.html twink] candid upskirt [http://webdialer.yaboo.dk/gay-sex/teen-muscle-hunk-gallery.html gay men] gays [http://webdialer.yaboo.dk/gay-sex/boys-gay-locker-room.html gay photography] voyeur upskirt [http://webdialer.yaboo.dk/gay-sex/gay-russian-boys.html gay boy] gay blowjobs [http://webdialer.yaboo.dk/gay-sex/male-muscle-hunk-galleries.html gay sex] gay orgy [http://webdialer.yaboo.dk/gay-sex/free-naked-hunks.html gay] spy [http://webdialer.yaboo.dk/gay-sex/nifty-gay-male-stories.html gay cock] voyeur sex [http://webdialer.yaboo.dk/gay-sex/hot-hunk.html gay hunks] free voyeur [http://webdialer.yaboo.dk/gay-sex/hunk-men.html free gay pics] hunk [http://webdialer.yaboo.dk/gay-sex/free-gay-streaming-videos.html free gay porn] girls flashing [http://webdialer.yaboo.dk/gay-sex/free-hardcore-gay-cum-shots.html hunk] gay wrestling [http://webdialer.yaboo.dk/gay-sex/twink-video.html gay incest] gay anal [http://webdialer.yaboo.dk/gay-sex/gay-men-locker-rooms.html hunk] spy [http://webdialer.yaboo.dk/gay-sex/male-hunks-naked.html twinks] gay cartoons [http://webdialer.yaboo.dk/gay-sex/straight-men-have-gay-fantasies.html gay anal] hot hunks [http://webdialer.yaboo.dk/gay-sex/naked-gay-males.html gay boy] voyeur beach [http://webdialer.yaboo.dk/gay-sex/gay-anal-cum-shots.html gay cock] totally spies hentai [http://webdialer.yaboo.dk/gay-sex/gay-boys-cum.html gay] college girls flashing [http://webdialer.yaboo.dk/gay-sex/gay-men-in-the-shower.html gay hunks] gay fuck [http://webdialer.yaboo.dk/gay-sex/gay-cum-facials.html gay porn] free gay porn [http://webdialer.yaboo.dk/gay-sex/college-hunk.html naked hunks] college girls flashing [http://webdialer.yaboo.dk/gay-sex/gay-porn-blog.html gay wrestling] spycam [http://webdialer.yaboo.dk/gay-sex/muscle-men-gay-hunks.html gay marriage] upskirt [http://webdialer.yaboo.dk/gay-sex/horny-hunks.html gay anal] hot hunks [http://webdialer.yaboo.dk/gay-sex/twink-porn.html gay wrestling] hunks [http://webdialer.yaboo.dk/gay-sex/boys-twinks.html gay] voyuerweb [http://webdialer.yaboo.dk/gay-sex/young-gay-penis.html gay photography] spy cameras [http://webdialer.yaboo.dk/gay-sex/horny-gay-men.html gay cartoons] spy [http://webdialer.yaboo.dk/gay-sex/twink-tgp.html twinks] gay teens [http://webdialer.yaboo.dk/gay-sex/gay-cock-sucker.html gay porn] hidden cam [http://webdialer.yaboo.dk/gay-sex/gay-male-cartoons.html gay photography] gay hentai
 
</div>
 
  
 
=Multiple processes=
 
=Multiple processes=

Revision as of 22:25, 15 January 2006

float
 This article is based on Visual Basic 6. Find other Visual Basic 6 articles.

Singleton objects are useful for sharing data between multiple callers.

Single process

A singleton to be shared throughout a single project is easy.

Public Singleton As New SingletonObject

As long as this is in a module, this variable (a single instance of the object) will be accessible from the entire project. Ideally, you should remove the "New" and use this once on startup

Set Singleton = New SingletonObject

Multiple processes

If you want to access a singleton object across multiple processes, you need to put in a bit more effort. As there can only be a single "owner", this will need to be a separate process (or ActiveX EXE) from all the callers that contains 3 important parts.

  • The singleton class
  • A public variable of the singleton class
  • A global class that allows access to the public variable

The variable is very much like the one used for the single process sample above as it is only directly accessed by (multiple instances of) the global class.

The global class only needs to contain a single function that will instantiate the singleton object if it hasn't been created already and then return it.

Public Function GetSingleton As SingletonObject
  If Singleton Is Nothing Then Set Singleton = New SingletonObject
  Set GetSingleton = Singleton
End Function

If any other caller then creates another instance of the global object and calls GetSingleton, it will return the already created object.

As soon as all references have been released or destroyed then it will cleanly shutdown.

Please note that this can't be done using COM DLLs as the "public" variables are private to each application.

Enjoy.