Click here to Skip to main content
15,899,314 members
Home / Discussions / C#
   

C#

 
GeneralRe: Managed C# Compiler question Pin
LongRange.Shooter13-Mar-03 10:53
LongRange.Shooter13-Mar-03 10:53 
GeneralRe: Managed C# Compiler question Pin
LongRange.Shooter19-Mar-03 10:29
LongRange.Shooter19-Mar-03 10:29 
QuestionSending commands between Windows applications? Pin
Kryal13-Mar-03 6:13
Kryal13-Mar-03 6:13 
AnswerRe: Sending commands between Windows applications? Pin
Davy Mitchell13-Mar-03 22:02
Davy Mitchell13-Mar-03 22:02 
QuestionHow to create global variables in C#? Pin
Vitaliy Vorontsov13-Mar-03 6:10
Vitaliy Vorontsov13-Mar-03 6:10 
AnswerRe: How to create global variables in C#? Pin
leppie13-Mar-03 6:36
leppie13-Mar-03 6:36 
AnswerRe: How to create global variables in C#? Pin
Xiangyang Liu 刘向阳13-Mar-03 6:40
Xiangyang Liu 刘向阳13-Mar-03 6:40 
AnswerRe: How to create global variables in C#? Pin
kaschimer13-Mar-03 6:40
kaschimer13-Mar-03 6:40 
AnswerRe: How to create global variables in C#? Pin
Robert Hinrichs13-Mar-03 7:45
Robert Hinrichs13-Mar-03 7:45 
GeneralRe: How to create global variables in C#? Pin
Jeff J13-Mar-03 8:16
Jeff J13-Mar-03 8:16 
AnswerRe: How to create global variables in C#? Pin
Adam Turner13-Mar-03 11:02
Adam Turner13-Mar-03 11:02 
QuestionHow to update a Windows Service Pin
Chris Hansson13-Mar-03 5:55
Chris Hansson13-Mar-03 5:55 
AnswerRe: How to update a Windows Service Pin
Xiangyang Liu 刘向阳13-Mar-03 6:27
Xiangyang Liu 刘向阳13-Mar-03 6:27 
GeneralDefault argument values Pin
Alexandru Savescu13-Mar-03 4:23
Alexandru Savescu13-Mar-03 4:23 
GeneralRe: Default argument values Pin
Daniel Turini13-Mar-03 4:45
Daniel Turini13-Mar-03 4:45 
GeneralRe: Default argument values Pin
Alexandru Savescu13-Mar-03 5:00
Alexandru Savescu13-Mar-03 5:00 
GeneralRe: Default argument values Pin
Daniel Turini13-Mar-03 5:17
Daniel Turini13-Mar-03 5:17 
GeneralRe: Default argument values Pin
Alexandru Savescu13-Mar-03 5:28
Alexandru Savescu13-Mar-03 5:28 
GeneralRe: Default argument values Pin
Andy Smith13-Mar-03 6:46
Andy Smith13-Mar-03 6:46 
GeneralRe: Default argument values Pin
Nick Parker13-Mar-03 8:22
protectorNick Parker13-Mar-03 8:22 
GeneralCasting userdefined parameter class Pin
Venkatraman12-Mar-03 20:18
Venkatraman12-Mar-03 20:18 
GeneralRe: Casting userdefined parameter class Pin
leppie13-Mar-03 6:19
leppie13-Mar-03 6:19 
GeneralSynchronized collections Pin
Don Miguel12-Mar-03 19:47
Don Miguel12-Mar-03 19:47 
GeneralRe: Synchronized collections Pin
Kannan Kalyanaraman12-Mar-03 21:24
Kannan Kalyanaraman12-Mar-03 21:24 
GeneralRe: Synchronized collections Pin
James T. Johnson13-Mar-03 11:33
James T. Johnson13-Mar-03 11:33 
Don Miguel wrote:
which is the need of Sychronized

Synchronized tells you if the collection's operations will be thread-safe. Generally this is done by implementing a wrapper around the collection, using a lock on the SyncRoot for each operation performed.

Don Miguel wrote:
which is the need of SyncRoot

SyncRoot is for doing your own locking. Say you need to add a lot of items to the collection, during which no other thread should use it. Rather than using the Synchronized wrapper which would lock/unlock for each operation you would create a lock on the SyncRoot object, then perform each of your operations.

Don Miguel wrote:
Aren't the collections thread safe??

No, you need to refer to the documentation for each class you wish to use to find out if the operations are thread-safe. Making everything thread-safe by default is expense CPU wise, so you are better off not putting it in for the cases where thread-safety isn't an issue.

Most collection classes expose some way of getting a Synchronized version, usually by a static method of some sort. Always check the documentation to be sure.

James

"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation

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.