Click here to Skip to main content
15,909,030 members
Home / Discussions / C#
   

C#

 
GeneralRe: Unregistering Event Pin
Martin#7-May-07 4:48
Martin#7-May-07 4:48 
GeneralRe: Unregistering Event Pin
Scott Dorman7-May-07 4:51
professionalScott Dorman7-May-07 4:51 
GeneralRe: Unregistering Event Pin
Martin#7-May-07 4:54
Martin#7-May-07 4:54 
Questiondatarelation in dataset Pin
shanthivasan26-Apr-07 2:02
shanthivasan26-Apr-07 2:02 
AnswerRe: datarelation in dataset Pin
stancrm26-Apr-07 2:56
stancrm26-Apr-07 2:56 
GeneralRe: datarelation in dataset Pin
shanthivasan26-Apr-07 18:57
shanthivasan26-Apr-07 18:57 
QuestionCheckbox field Pin
Muammar©26-Apr-07 1:56
Muammar©26-Apr-07 1:56 
AnswerRe: Checkbox field Pin
kubben26-Apr-07 2:31
kubben26-Apr-07 2:31 
GeneralRe: Checkbox field Pin
Muammar©26-Apr-07 3:20
Muammar©26-Apr-07 3:20 
QuestionPost-Build-Step: Copy New Files Pin
Tomerland26-Apr-07 1:38
Tomerland26-Apr-07 1:38 
AnswerRe: Post-Build-Step: Copy New Files Pin
Christian Graus26-Apr-07 1:54
protectorChristian Graus26-Apr-07 1:54 
QuestionDataGridView and Animated gif Problem! Pin
mertkan6526-Apr-07 0:45
mertkan6526-Apr-07 0:45 
QuestionDifference between SyncRoot property and Synchronized method? Pin
kumar.bs26-Apr-07 0:12
kumar.bs26-Apr-07 0:12 
AnswerRe: Difference between SyncRoot property and Synchronized method? Pin
Sathesh Sakthivel26-Apr-07 0:21
Sathesh Sakthivel26-Apr-07 0:21 
GeneralRe: Difference between SyncRoot property and Synchronized method? Pin
kumar.bs26-Apr-07 0:32
kumar.bs26-Apr-07 0:32 
GeneralRe: Difference between SyncRoot property and Synchronized method? Pin
Sathesh Sakthivel26-Apr-07 0:35
Sathesh Sakthivel26-Apr-07 0:35 
AnswerRe: Difference between SyncRoot property and Synchronized method? Pin
peterchen26-Apr-07 6:41
peterchen26-Apr-07 6:41 
Synchronized returns a collection that locks on each call, i.e. while you call a method or property, no other thread may modify the collection. This is convenient, but not enough.

Imagine the following code snippet:

// remove head
if (myList.Count > 0)
  myList.RemoveAt(0); 


In this case, you have two separate calls (querying "Count" and removing an object). However, between the calls, some other thread may access the list and e.g. clear it completely. In this case, RemoveAt will fail.

For that scenario, you get the SyncRoot:

lock(myList.SyncRoot)
{
  if (myList.Count > 0)
    myList.RemoveAt(0); 
}




We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
My first real C# project | Linkify!|FoldWithUs! | sighist

GeneralRe: Difference between SyncRoot property and Synchronized method? Pin
kumar.bs26-Apr-07 18:33
kumar.bs26-Apr-07 18:33 
GeneralRe: Difference between SyncRoot property and Synchronized method? Pin
peterchen27-Apr-07 3:20
peterchen27-Apr-07 3:20 
GeneralRe: Difference between SyncRoot property and Synchronized method? Pin
kumar.bs29-Apr-07 21:05
kumar.bs29-Apr-07 21:05 
QuestionUrgent: How to refresh the status bar during a process Pin
dudedotnet26-Apr-07 0:09
dudedotnet26-Apr-07 0:09 
AnswerRe: Urgent: How to refresh the status bar during a process Pin
Christian Graus26-Apr-07 0:25
protectorChristian Graus26-Apr-07 0:25 
GeneralRe: Urgent: How to refresh the status bar during a process Pin
dudedotnet26-Apr-07 0:31
dudedotnet26-Apr-07 0:31 
GeneralRe: Urgent: How to refresh the status bar during a process Pin
Christian Graus26-Apr-07 0:39
protectorChristian Graus26-Apr-07 0:39 
Questionvalidation (double) Pin
Keshav V. Kamat25-Apr-07 23:42
Keshav V. Kamat25-Apr-07 23:42 

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.