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

C#

 
GeneralRe: Debugging Hash Table Pin
Jeff Varszegi26-Apr-04 3:36
professionalJeff Varszegi26-Apr-04 3:36 
GeneralRe: Debugging Hash Table Pin
Heath Stewart26-Apr-04 3:38
protectorHeath Stewart26-Apr-04 3:38 
GeneralRe: Debugging Hash Table Pin
Kannan Kalyanaraman26-Apr-04 8:20
Kannan Kalyanaraman26-Apr-04 8:20 
GeneralRe: Debugging Hash Table Pin
Heath Stewart26-Apr-04 8:24
protectorHeath Stewart26-Apr-04 8:24 
GeneralConsole in Windows Pin
sreejith ss nair25-Apr-04 21:11
sreejith ss nair25-Apr-04 21:11 
GeneralRe: Console in Windows Pin
hammackj26-Apr-04 1:01
hammackj26-Apr-04 1:01 
GeneralQuestion about synchronization Pin
hsupercn25-Apr-04 20:42
hsupercn25-Apr-04 20:42 
GeneralRe: Question about synchronization Pin
Jeff Varszegi25-Apr-04 21:08
professionalJeff Varszegi25-Apr-04 21:08 
Yep, that will work. I usually create an extra object to lock on, though, whether I'm working in a static or instance context; that goes for Java, too. Why? Because I think that an object should control its own destiny; its code shouldn't block indefinitely because some jerkoff decided to write code that locked the object or class externally. Unless that's desired behavior, of course. Smile | :) Know what I mean, though? Check out the SyncRoot property, where the .NET designers apparently decided the same thing. The same sort of thinking is exposed in Java APIs too.

Obviously, if you're creating a zillion objects that may be locked on, you don't want to create an extra object for each one just to accomplish this. However, I try to avoid creating zillions of objects in my code anyway; this means that most of my objects, especially the ones that I need to synchronize on, are pretty large and/or long-lived, hence the overhead of creating a tiny empty object is negligible. Add to that judicious use of the Immutable Object pattern, and I'm able to synchronize "cleanly" with no appreciable overhead.

[EDIT]One more thing-- even if you're going to use the type itself to lock on in a static context, you should probably store it as a static variable instead of getting it over... and over... and over again. [/EDIT]

Regards,

Jeff Varszegi
GeneralRe: Question about synchronization Pin
Heath Stewart26-Apr-04 3:16
protectorHeath Stewart26-Apr-04 3:16 
GeneralRe: Question about synchronization Pin
Jeff Varszegi26-Apr-04 4:20
professionalJeff Varszegi26-Apr-04 4:20 
GeneralRe: Question about synchronization Pin
Heath Stewart26-Apr-04 4:25
protectorHeath Stewart26-Apr-04 4:25 
GeneralRe: Question about synchronization Pin
Mike Dimmick26-Apr-04 0:45
Mike Dimmick26-Apr-04 0:45 
GeneralRe: Question about synchronization Pin
Jeff Varszegi26-Apr-04 4:23
professionalJeff Varszegi26-Apr-04 4:23 
GeneralEvaluating expressions Pin
Yaron K.25-Apr-04 20:04
Yaron K.25-Apr-04 20:04 
GeneralRe: Evaluating expressions Pin
Jeff Varszegi25-Apr-04 20:37
professionalJeff Varszegi25-Apr-04 20:37 
GeneralRe: Evaluating expressions Pin
Yaron K.25-Apr-04 20:45
Yaron K.25-Apr-04 20:45 
GeneralRe: Evaluating expressions Pin
Jeff Varszegi25-Apr-04 21:01
professionalJeff Varszegi25-Apr-04 21:01 
GeneralRe: Evaluating expressions Pin
Yaron K.26-Apr-04 1:35
Yaron K.26-Apr-04 1:35 
GeneralRe: Evaluating expressions Pin
Jeff Varszegi25-Apr-04 22:45
professionalJeff Varszegi25-Apr-04 22:45 
GeneralRe: Evaluating expressions Pin
Heath Stewart26-Apr-04 3:13
protectorHeath Stewart26-Apr-04 3:13 
GeneralClass Circular References Pin
Abner Mallidy25-Apr-04 18:40
Abner Mallidy25-Apr-04 18:40 
GeneralRe: Class Circular References Pin
Jeff Varszegi25-Apr-04 19:55
professionalJeff Varszegi25-Apr-04 19:55 
Questionhow to draw on a bitmap? Pin
lowiq25-Apr-04 18:08
lowiq25-Apr-04 18:08 
AnswerRe: how to draw on a bitmap? Pin
CWIZO25-Apr-04 21:25
CWIZO25-Apr-04 21:25 
GeneralRe: how to draw on a bitmap? Pin
lowiq25-Apr-04 21:58
lowiq25-Apr-04 21:58 

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.