Click here to Skip to main content
16,005,281 members
Home / Discussions / C#
   

C#

 
GeneralRe: A wonder of double convert to integer Pin
Guffa14-Sep-05 3:12
Guffa14-Sep-05 3:12 
Questionwhy I Can't Get Monitor Information Using PrintMon.exe! Pin
szcococut13-Sep-05 15:45
szcococut13-Sep-05 15:45 
Questionmessage formatter Pin
mikenater13-Sep-05 14:02
mikenater13-Sep-05 14:02 
AnswerRe: message formatter Pin
Mohamad Al Husseiny13-Sep-05 14:07
Mohamad Al Husseiny13-Sep-05 14:07 
GeneralRe: message formatter Pin
mikenater22-Sep-05 17:35
mikenater22-Sep-05 17:35 
QuestionTaking over another window Pin
Member 239309213-Sep-05 13:11
Member 239309213-Sep-05 13:11 
AnswerRe: Taking over another window Pin
Mohamad Al Husseiny13-Sep-05 14:04
Mohamad Al Husseiny13-Sep-05 14:04 
QuestionSingle Instance Form? Pin
MrR_13-Sep-05 11:16
MrR_13-Sep-05 11:16 
Hi all

I'm trying to implement a form that can only display one instance at a time. Note that this isn't the first form of the application - I'm not trying to build a single instance app. I just want one of the forms to display only once when a button on the form called at startup is clicked. I've got this working for the most part by implementing it as a singleton but run into problems when the form is closed and I try to open it by clicking the button again. The code I'm using is:

public partial class Singleton : Form
{
private static Singleton instance = null;

private Singleton()
{
InitializeComponent();
}

public static Singleton Instance
{
get
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
}

~ Singleton()
{
instance = null;
}
}

I was under the impression that the destructor would resolve the issue I'm having but it hasn't. I receive the following exception:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Singleton'.

Could anyone suggest how I can resolve this issue or suggest another approach to a single instance form that can be launched and closed more than once from the main form of the app?

Thanks in advance

MrR_

Nothing is foolproof to the talented fool.
AnswerRe: Single Instance Form? Pin
QuietKnight13-Sep-05 11:27
QuietKnight13-Sep-05 11:27 
AnswerRe: Single Instance Form? Pin
Mohamad Al Husseiny13-Sep-05 11:51
Mohamad Al Husseiny13-Sep-05 11:51 
GeneralRe: Single Instance Form? Pin
MrR_13-Sep-05 12:17
MrR_13-Sep-05 12:17 
QuestionGrab Text From Other Window Pin
Afief13-Sep-05 11:06
Afief13-Sep-05 11:06 
AnswerRe: Grab Text From Other Window Pin
Mohamad Al Husseiny13-Sep-05 16:28
Mohamad Al Husseiny13-Sep-05 16:28 
GeneralRe: Grab Text From Other Window Pin
Afief13-Sep-05 19:39
Afief13-Sep-05 19:39 
Questionhow export datagrid to excell Pin
ashish2001mca13-Sep-05 10:48
ashish2001mca13-Sep-05 10:48 
AnswerRe: how export datagrid to excell Pin
Mohamad Al Husseiny13-Sep-05 11:17
Mohamad Al Husseiny13-Sep-05 11:17 
QuestionI want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
shanzy13-Sep-05 10:30
shanzy13-Sep-05 10:30 
AnswerRe: I want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
QuietKnight13-Sep-05 11:11
QuietKnight13-Sep-05 11:11 
GeneralRe: I want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
shanzy13-Sep-05 19:02
shanzy13-Sep-05 19:02 
AnswerRe: I want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
Luis Alonso Ramos13-Sep-05 14:09
Luis Alonso Ramos13-Sep-05 14:09 
GeneralRe: I want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
shanzy13-Sep-05 19:27
shanzy13-Sep-05 19:27 
AnswerRe: I want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
Daniel Turini13-Sep-05 21:08
Daniel Turini13-Sep-05 21:08 
GeneralRe: I want using the method "system("PAUSE");" in C#, but I cannot find which namespace it blog to? Pin
shanzy13-Sep-05 21:37
shanzy13-Sep-05 21:37 
QuestionRegex find Date in HTML Response String Pin
surfman1913-Sep-05 10:21
surfman1913-Sep-05 10:21 
AnswerRe: Regex find Date in HTML Response String Pin
User 665813-Sep-05 12:34
User 665813-Sep-05 12:34 

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.