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

C#

 
AnswerRe: Naming Conventions Pin
Simon P Stevens17-Nov-08 23:50
Simon P Stevens17-Nov-08 23:50 
AnswerRe: Naming Conventions Pin
Eddy Vluggen18-Nov-08 2:39
professionalEddy Vluggen18-Nov-08 2:39 
AnswerRe: Naming Conventions Pin
Nagy Vilmos18-Nov-08 2:43
professionalNagy Vilmos18-Nov-08 2:43 
QuestionExternal libraries / Threading / Critical sections Pin
J4amieC17-Nov-08 23:25
J4amieC17-Nov-08 23:25 
AnswerRe: External libraries / Threading / Critical sections Pin
Simon P Stevens18-Nov-08 0:08
Simon P Stevens18-Nov-08 0:08 
Just a couple of comments:

1) Your lock and if statement are backwards. 2 threads could get past the if statement. One would pass the lock and do the init, the other would hang at the lock. When the first exited the lock, the second would then be released and pass the lock and do the init again.

2) I wouldn't lock on the instance. Mainly because it's public (advised against). If you must use a lock, create a private lock object instead.

3) I wouldn't put the shut down code in a finaliser. Finalisers aren't guaranteed to be run, and if a finaliser blocks or throws an exception it can screw up your garbage collector thread - You definitely shouldn't be throwing exceptions from a finaliser, it will kill the garbage collector, and the exception will never get reported. I'd do it with a dispose pattern (and put the code inside the if block so it's only called when disposing and not when finalising) and make sure you call dispose manually from your applications shutdown routines.

4) It's a singleton. That means the constructor only gets called once. You've used a thread safe singleton patten, so unless I've missed something I think you don't need the initialised flag or the lock at all. Just ditch the lock and flag entirely and trust the singleton pattern to only create the object and call the constructor once.

Simon

QuestionBinary Tree - Next Highest Value Pin
Map Idea17-Nov-08 23:12
Map Idea17-Nov-08 23:12 
AnswerRe: Binary Tree - Next Highest Value Pin
Simon P Stevens17-Nov-08 23:44
Simon P Stevens17-Nov-08 23:44 
Questionrestart a console application Pin
caradri17-Nov-08 23:05
caradri17-Nov-08 23:05 
AnswerRe: restart a console application Pin
Simon P Stevens17-Nov-08 23:33
Simon P Stevens17-Nov-08 23:33 
QuestionFlip Pin
vinay_K17-Nov-08 23:00
vinay_K17-Nov-08 23:00 
AnswerRe: Flip Pin
dan!sh 17-Nov-08 23:06
professional dan!sh 17-Nov-08 23:06 
GeneralRe: Flip Pin
vinay_K17-Nov-08 23:28
vinay_K17-Nov-08 23:28 
GeneralRe: Flip Pin
dan!sh 18-Nov-08 0:12
professional dan!sh 18-Nov-08 0:12 
AnswerRe: Flip Pin
sph3rex17-Nov-08 23:06
sph3rex17-Nov-08 23:06 
QuestionHow to register COM component and use in c# window application Pin
veereshIndia17-Nov-08 22:38
veereshIndia17-Nov-08 22:38 
AnswerRe: How to register COM component and use in c# window application Pin
JoeSharp17-Nov-08 22:57
JoeSharp17-Nov-08 22:57 
GeneralRe: How to register COM component and use in c# window application Pin
veereshIndia17-Nov-08 23:26
veereshIndia17-Nov-08 23:26 
GeneralRe: How to register COM component and use in c# window application Pin
JoeSharp17-Nov-08 23:34
JoeSharp17-Nov-08 23:34 
GeneralRe: How to register COM component and use in c# window application Pin
veereshIndia17-Nov-08 23:44
veereshIndia17-Nov-08 23:44 
AnswerRe: How to register COM component and use in c# window application Pin
Simon P Stevens17-Nov-08 23:02
Simon P Stevens17-Nov-08 23:02 
AnswerCP IGNORE: Crossposted about a dozen times... Pin
Dave Kreskowiak18-Nov-08 2:09
mveDave Kreskowiak18-Nov-08 2:09 
QuestionIs possible to create or DLL/OCX by using C# and use in VB6? Pin
cocoonwls17-Nov-08 22:32
cocoonwls17-Nov-08 22:32 
AnswerRe: Is possible to create or DLL/OCX by using C# and use in VB6? Pin
Pedram Behroozi17-Nov-08 22:46
Pedram Behroozi17-Nov-08 22:46 
AnswerRe: Is possible to create or DLL/OCX by using C# and use in VB6? Pin
Eddy Vluggen18-Nov-08 3:14
professionalEddy Vluggen18-Nov-08 3:14 
QuestionHow do you talk to a remote serial port over a network? Pin
alb1081117-Nov-08 22:04
alb1081117-Nov-08 22:04 

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.