Click here to Skip to main content
15,883,883 members
Home / Discussions / C#
   

C#

 
GeneralAsynchronous Delegates Pin
Ryan Binns20-Aug-03 17:18
Ryan Binns20-Aug-03 17:18 
GeneralRe: Asynchronous Delegates Pin
J. Dunlap20-Aug-03 18:06
J. Dunlap20-Aug-03 18:06 
GeneralRe: Asynchronous Delegates Pin
Ryan Binns20-Aug-03 18:14
Ryan Binns20-Aug-03 18:14 
GeneralRe: Asynchronous Delegates Pin
J. Dunlap20-Aug-03 18:19
J. Dunlap20-Aug-03 18:19 
GeneralRe: Asynchronous Delegates Pin
Ryan Binns20-Aug-03 18:57
Ryan Binns20-Aug-03 18:57 
GeneralRe: Asynchronous Delegates Pin
J. Dunlap20-Aug-03 19:05
J. Dunlap20-Aug-03 19:05 
GeneralTracking Object Creation of Remotable Object Pin
Ozyris20-Aug-03 15:40
Ozyris20-Aug-03 15:40 
GeneralRe: Tracking Object Creation of Remotable Object Pin
Okeno Palmer21-Aug-03 6:57
Okeno Palmer21-Aug-03 6:57 
I don't know much about remoting but the idea of a singelton is that there will only be one instance of it during the lifetime of the application. This is usually accomplished by making the varaible a static. Note that there will really only ever be just 1 instance of your Singleton if that is the case.

One approach is to have a static tracker that is incremented in the constructor of your Singleton class and decremented in the destructor.

Ex:

class SingleFella
{
private static int tracker = 0;
private static SingleFella m_instance = null;

public static SingleFella GetInstance()
{
if( m_instance == null )
m_instance = new SingleFella();
return m_instance;
}

public static void DestroyInstance()
{
m_instance = null;
}

private SingleFella()
{
tracker++;
System.Console.WriteLine("Tracker (Constructor)= " + tracker);
}

~SingleFella()
{
tracker--;
m_instance = null;
System.Console.WriteLine("Tracker (Destructor)= " + tracker);
}

public static void Main(String [] args)
{
SingleFella instance1 = SingleFella.GetInstance();
SingleFella instance2 = SingleFella.GetInstance();
SingleFella instance3 = SingleFella.GetInstance();
SingleFella instance4 = SingleFella.GetInstance();
SingleFella.DestroyInstance();
}
}

Give that sample a run and move around the call to DestroyInstance() and you will see the effect.

I'm not quite sure if this is what you are looking for but this is how the Singleton Design Pattern works.

..:: Keno ::..
QuestionHow to make DataGrid column read only at runtime Pin
sumeat20-Aug-03 14:58
sumeat20-Aug-03 14:58 
AnswerRe: How to make DataGrid column read only at runtime Pin
Ista20-Aug-03 16:10
Ista20-Aug-03 16:10 
GeneralRe: How to make DataGrid column read only at runtime Pin
sumeat21-Aug-03 7:59
sumeat21-Aug-03 7:59 
GeneralRe: How to make DataGrid column read only at runtime Pin
Ista21-Aug-03 9:43
Ista21-Aug-03 9:43 
AnswerRe: How to make DataGrid column read only at runtime Pin
A.Wegierski21-Aug-03 7:48
A.Wegierski21-Aug-03 7:48 
GeneralCan't get manifest to work for my xp style controls Pin
IrishSonic20-Aug-03 14:33
IrishSonic20-Aug-03 14:33 
GeneralRe: Can't get manifest to work for my xp style controls Pin
eggie520-Aug-03 17:15
eggie520-Aug-03 17:15 
GeneralHTML to PDF Pin
Iftikhar Ahmad Dar20-Aug-03 11:56
Iftikhar Ahmad Dar20-Aug-03 11:56 
GeneralRe: HTML to PDF Pin
Ista20-Aug-03 14:34
Ista20-Aug-03 14:34 
GeneralRe: HTML to PDF Pin
leppie21-Aug-03 7:04
leppie21-Aug-03 7:04 
GeneraldataGrid1.Width is acting funny Pin
Anonymous20-Aug-03 11:15
Anonymous20-Aug-03 11:15 
GeneralRe: dataGrid1.Width is acting funny Pin
Ista20-Aug-03 14:35
Ista20-Aug-03 14:35 
GeneralRe: dataGrid1.Width is acting funny Pin
A.Wegierski21-Aug-03 7:53
A.Wegierski21-Aug-03 7:53 
GeneralMDI question in C++.Net Pin
Qbus20-Aug-03 11:04
Qbus20-Aug-03 11:04 
GeneralRe: MDI question in C++.Net Pin
Ista20-Aug-03 14:36
Ista20-Aug-03 14:36 
GeneralNeed Help! Pin
t_m2002052120-Aug-03 10:36
t_m2002052120-Aug-03 10:36 
GeneralRe: Need Help! Pin
Ista20-Aug-03 14:37
Ista20-Aug-03 14:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.