Re: Globally accessible variables and functions?
From: Marina (someone_at_nospam.com)
Date: 04/08/04
- Next message: Paul Clement: "Re: fetch image data from access database to picture box in vb.net"
- Previous message: Marina: "Re: ado.net"
- In reply to: Dougal Fair: "Re: Globally accessible variables and functions?"
- Next in thread: Armin Zingler: "Re: Globally accessible variables and functions?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Apr 2004 16:01:27 -0400
So then what's the difference between a singleton class, and a class with
all shared members? I mean as far as the end result of what you are trying
to accomplish.
"Dougal Fair" <dougal@dougalfair.com> wrote in message
news:40759dde.767702359@news.goldengate.net...
> On Thu, 8 Apr 2004 19:33:48 +0200, "Cor Ligthert"
> <notfirstname@planet.nl> wrote:
>
> >Hi Douglas,
> >
> >I do not understand what you mean, with pay for that overhead, recreating
> >gives the posibility to free resources.
>
> I fill in some values of a few data members in the new() function - so
> there's that overhead, performance-wise.
>
>
> >
> >However what you ask is called in VB.net a Shared class, you make that by
> >setting all the methods and properties shared.
>
>
> But that doesn't create the member variables and initialize them, etc.
>
> I think I found the answer in making a "singleton" class - the class
> contains an instance of itself, and I use a function I'll call
> "Create", which will do:
>
>
> Public Shared Function Create() As clsMyApplication
> If oApp Is Nothing Then
> oApp = New clsMyApplication
> End If
>
> Return oMyApp
> End Function
>
>
> And then, wherever I need this object, I just "create" it:
>
> dim oMyApp As clsMyApplication = oMyApp.Create()
>
> Which will create the object if necessary, but otherwise will use the
> one that is already created. It seems to work well.
>
> >
>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html
/vaconsharedmembers.asp
> >
> >
> >I hope this helps?
> >
> >Cor
> >
> >
>
- Next message: Paul Clement: "Re: fetch image data from access database to picture box in vb.net"
- Previous message: Marina: "Re: ado.net"
- In reply to: Dougal Fair: "Re: Globally accessible variables and functions?"
- Next in thread: Armin Zingler: "Re: Globally accessible variables and functions?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|