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

C#

 
GeneralRe: Lock(This) Pin
Ennis Ray Lynch, Jr.10-Aug-09 5:55
Ennis Ray Lynch, Jr.10-Aug-09 5:55 
GeneralRe: Lock(This) Pin
jpk42010-Aug-09 5:57
jpk42010-Aug-09 5:57 
GeneralRe: Lock(This) Pin
Luc Pattyn10-Aug-09 6:06
sitebuilderLuc Pattyn10-Aug-09 6:06 
GeneralRe: Lock(This) Pin
jpk42010-Aug-09 6:28
jpk42010-Aug-09 6:28 
GeneralRe: Lock(This) Pin
Luc Pattyn10-Aug-09 6:38
sitebuilderLuc Pattyn10-Aug-09 6:38 
GeneralRe: Lock(This) Pin
PIEBALDconsult10-Aug-09 7:04
mvePIEBALDconsult10-Aug-09 7:04 
GeneralRe: Lock(This) Pin
Luc Pattyn10-Aug-09 7:10
sitebuilderLuc Pattyn10-Aug-09 7:10 
AnswerRe: Lock(This) Pin
Leonardo Muzzi10-Aug-09 7:18
Leonardo Muzzi10-Aug-09 7:18 
The problem with Lock(this) and Lock(type) is that these objects are public, so an external code could lock on them. So if your class is named YourClass, I can make a code like this:

YourClass obj = new YourClass();
lock(obj){ ... }



And that would probably deadlock your internal code. Same problem for a public type. Since it is commom to lock an object that you want to protect, it's not too dificult for a code like this to happen.

The best approach is to create an object just for locking on it, instead of locking the class object. Make this locking object "static" and you get the same effect of locking a type.

Regards,

Leonardo Muzzi

Questionq in datagridview Pin
mohammad alnoed10-Aug-09 4:56
mohammad alnoed10-Aug-09 4:56 
AnswerRe: q in datagridview Pin
RobScripta10-Aug-09 9:13
professionalRobScripta10-Aug-09 9:13 
Questiontreeview scroll event Pin
Surya Ayyagari10-Aug-09 3:49
Surya Ayyagari10-Aug-09 3:49 
AnswerRe: treeview scroll event Pin
0x3c010-Aug-09 4:31
0x3c010-Aug-09 4:31 
GeneralRe: treeview scroll event Pin
Surya Ayyagari10-Aug-09 17:52
Surya Ayyagari10-Aug-09 17:52 
QuestionForm Events Pin
Member 368144310-Aug-09 2:36
Member 368144310-Aug-09 2:36 
AnswerRe: Form Events Pin
Luc Pattyn10-Aug-09 2:51
sitebuilderLuc Pattyn10-Aug-09 2:51 
QuestionDatabase Problem, Unknown Information in a Access DataBase by the MEMO type! Pin
maysam gamini10-Aug-09 2:05
maysam gamini10-Aug-09 2:05 
AnswerRe: Database Problem, Unknown Information in a Access DataBase by the MEMO type! Pin
Luc Pattyn10-Aug-09 2:54
sitebuilderLuc Pattyn10-Aug-09 2:54 
AnswerRe: Database Problem, Unknown Information in a Access DataBase by the MEMO type! Pin
Leonardo Muzzi10-Aug-09 2:58
Leonardo Muzzi10-Aug-09 2:58 
GeneralRe: Database Problem, Unknown Information in a Access DataBase by the MEMO type! Pin
maysam gamini10-Aug-09 3:29
maysam gamini10-Aug-09 3:29 
GeneralRe: Database Problem, Unknown Information in a Access DataBase by the MEMO type! Pin
Leonardo Muzzi10-Aug-09 4:12
Leonardo Muzzi10-Aug-09 4:12 
QuestionCapture the Web Cam Video In LAN Network using C# Code Pin
vasanth arivali10-Aug-09 2:01
vasanth arivali10-Aug-09 2:01 
AnswerRe: Capture the Web Cam Video In LAN Network using C# Code Pin
Hristo-Bojilov10-Aug-09 2:06
Hristo-Bojilov10-Aug-09 2:06 
QuestionCalling a Form By selecting a date on the Month Callender Pin
Shocker0110-Aug-09 1:46
Shocker0110-Aug-09 1:46 
AnswerRe: Calling a Form By selecting a date on the Month Callender Pin
Ashfield10-Aug-09 9:36
Ashfield10-Aug-09 9:36 
QuestionInheritance Pin
p_196010-Aug-09 1:36
p_196010-Aug-09 1:36 

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.