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

C#

 
AnswerRe: Block a method execution Pin
Calla19-Apr-10 20:08
Calla19-Apr-10 20:08 
GeneralRe: Block a method execution Pin
Hum Dum19-Apr-10 20:18
Hum Dum19-Apr-10 20:18 
GeneralRe: Block a method execution Pin
Calla19-Apr-10 20:39
Calla19-Apr-10 20:39 
GeneralRe: Block a method execution Pin
Michel Godfroid19-Apr-10 21:12
Michel Godfroid19-Apr-10 21:12 
GeneralRe: Block a method execution Pin
Calla19-Apr-10 21:18
Calla19-Apr-10 21:18 
JokeRe: Block a method execution Pin
Michel Godfroid19-Apr-10 21:22
Michel Godfroid19-Apr-10 21:22 
GeneralRe: Block a method execution Pin
Mycroft Holmes19-Apr-10 22:47
professionalMycroft Holmes19-Apr-10 22:47 
GeneralRe: Block a method execution Pin
Michel Godfroid19-Apr-10 23:14
Michel Godfroid19-Apr-10 23:14 
I suppose he could, but this should only be used when writing a complete program, where you control every aspect of the project.
If on the other hand, you're writing a class library, where you want to ensure that some classes/methods are thread safe, it's best to keep the mutex objects together with the data they're supposed to be protecting.
I usually have one static object in the program, which contains references to resources that must be shared between threads. If a thread needs to instantiate a new shared object, it will use a method in that class, and the new() statement will be protected by a lock. In this way, I can ensure that objects which should be instantiated once are initiated only once.
This is basically an implementation of the singleton pattern.
http://www.yoda.arachsys.com/csharp/singleton.html[^]
GeneralRe: Block a method execution Pin
Hum Dum19-Apr-10 21:28
Hum Dum19-Apr-10 21:28 
GeneralRe: Block a method execution Pin
Hum Dum20-Apr-10 1:53
Hum Dum20-Apr-10 1:53 
GeneralRe: Block a method execution Pin
Michel Godfroid20-Apr-10 4:35
Michel Godfroid20-Apr-10 4:35 
Questionhow to display current time. Pin
sudhir behera19-Apr-10 17:59
sudhir behera19-Apr-10 17:59 
AnswerRe: how to display current time. Pin
Harvey Saayman19-Apr-10 18:03
Harvey Saayman19-Apr-10 18:03 
AnswerRe: how to display current time. Pin
Abhinav S19-Apr-10 18:10
Abhinav S19-Apr-10 18:10 
AnswerRe: how to display current time. Pin
Dr.Walt Fair, PE19-Apr-10 18:16
professionalDr.Walt Fair, PE19-Apr-10 18:16 
AnswerRe: how to display current time. Pin
Luc Pattyn20-Apr-10 1:13
sitebuilderLuc Pattyn20-Apr-10 1:13 
QuestionSystem.OutOfMemoryException when creating big array Pin
Xmen Real 19-Apr-10 17:17
professional Xmen Real 19-Apr-10 17:17 
AnswerRe: System.OutOfMemoryException when creating big array Pin
Not Active19-Apr-10 17:22
mentorNot Active19-Apr-10 17:22 
GeneralRe: System.OutOfMemoryException when creating big array Pin
Xmen Real 19-Apr-10 17:27
professional Xmen Real 19-Apr-10 17:27 
GeneralRe: System.OutOfMemoryException when creating big array Pin
Not Active19-Apr-10 18:01
mentorNot Active19-Apr-10 18:01 
GeneralRe: System.OutOfMemoryException when creating big array Pin
Xmen Real 19-Apr-10 21:07
professional Xmen Real 19-Apr-10 21:07 
GeneralRe: System.OutOfMemoryException when creating big array Pin
Matty2219-Apr-10 20:44
Matty2219-Apr-10 20:44 
AnswerRe: System.OutOfMemoryException when creating big array Pin
Dave Kreskowiak19-Apr-10 18:34
mveDave Kreskowiak19-Apr-10 18:34 
GeneralRe: System.OutOfMemoryException when creating big array Pin
Xmen Real 19-Apr-10 21:03
professional Xmen Real 19-Apr-10 21:03 
GeneralRe: System.OutOfMemoryException when creating big array Pin
Matty2219-Apr-10 21:09
Matty2219-Apr-10 21:09 

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.