Click here to Skip to main content
15,887,836 members
Home / Discussions / C#
   

C#

 
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 
SyncRoot Property:

Gets an object that can be used to synchronize access to the collection.

public virtual object SyncRoot {get;}

Property Value:
An object that can be used to synchronize access to the collection.

Synchronized Methods:
Synchronisation plays an important role in multithreaded applications where the threads are not independent of each other and share common resources. This is because if two threads share common resources and try to manipulate the resources simultaneously, the resources become inconsistent. To tackle such situations synchronisation provides a lock on the resource that is shared among threads and makes a thread wait until the other thread finishes the job with the resource. Thus synchronisation ‘locks’ the shared resource and prevents another thread from using it.

C# provides a lock keyword to lock the shared object or resource. Whatever is written inside the parenthesis following the lock keyword gets locked for the current thread and no other thread is permitted to obtain the lock on that resource or object. We can write an expression that evaluates to an object, or just the object on which we wish to have a lock, inside the parenthesis. Whatever the expression may be, the result should be a reference type. The code that uses the object to be synchronised should be written inside the block of the lock statement.
To give you a more concrete example, consider two threads working on a file. If both the threads try to open the file and write to it simultaneously, an exception is thrown. Here what we need to do is synchronise both the threads in such a way that only one thread opens the file and writes in it at any given moment.



Regards,

Satips.

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 
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 
AnswerRe: validation (double) Pin
Pete O'Hanlon26-Apr-07 0:12
mvePete O'Hanlon26-Apr-07 0:12 
Questionupload file Pin
nilima Dash25-Apr-07 23:29
nilima Dash25-Apr-07 23:29 
AnswerRe: upload file Pin
Christian Graus26-Apr-07 0:21
protectorChristian Graus26-Apr-07 0:21 
AnswerRe: upload file Pin
marky77726-Apr-07 1:42
marky77726-Apr-07 1:42 
QuestionHow to use Math Equation [of Word] in my software? Pin
Majid_grok25-Apr-07 23:14
Majid_grok25-Apr-07 23:14 
AnswerRe: How to use Math Equation [of Word] in my software? Pin
Aaron VanWieren26-Apr-07 5:19
Aaron VanWieren26-Apr-07 5:19 

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.