Click here to Skip to main content
15,881,781 members
Home / Discussions / C#
   

C#

 
GeneralRe: GAC / Reference / VStudio Pin
Heath Stewart23-Jan-04 4:44
protectorHeath Stewart23-Jan-04 4:44 
GeneralMultiple InternetExplorer objects' DownloadComplete event Pin
profoundwhispers23-Jan-04 0:07
profoundwhispers23-Jan-04 0:07 
GeneralRe: Multiple InternetExplorer objects' DownloadComplete event Pin
Mazdak23-Jan-04 2:20
Mazdak23-Jan-04 2:20 
GeneralRe: Multiple InternetExplorer objects' DownloadComplete event Pin
profoundwhispers23-Jan-04 4:17
profoundwhispers23-Jan-04 4:17 
GeneralRe: Multiple InternetExplorer objects' DownloadComplete event Pin
Mazdak23-Jan-04 4:34
Mazdak23-Jan-04 4:34 
GeneralRe: Multiple InternetExplorer objects' DownloadComplete event Pin
Heath Stewart23-Jan-04 4:42
protectorHeath Stewart23-Jan-04 4:42 
GeneralRe: Multiple InternetExplorer objects' DownloadComplete event Pin
profoundwhispers23-Jan-04 4:53
profoundwhispers23-Jan-04 4:53 
GeneralRe: Multiple InternetExplorer objects' DownloadComplete event Pin
Heath Stewart23-Jan-04 4:58
protectorHeath Stewart23-Jan-04 4:58 
You have to lock against the same object (for example, the Type of the current object will always be the same) otherwise the lock doesn't make a difference. Take a look at the System.Threading namespace, specifically the Monitor class (which the lock keyword compiles down to like the following):
Monitor.Enter(syncRoot);
try
{
  // Do synchronized stuff.
}
finally
{
  Monitor.Exit(syncRoot);
}
If the object called syncRoot is different for every call, the monitor will lock against different objects and will not block pending requests to enter the synchronized section.

There are two things you should take into consideration when choosing an object to lock. If you want a method (especially a static method) to be synchronized, lock against a static object (such as the Type, which is recommended, but you can use a static object reference as well). If you want methods to be synchronized only for a given instance, lock against an object member of the instance of your class.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralHelp with Collections Pin
crushinghellhammer22-Jan-04 18:19
crushinghellhammer22-Jan-04 18:19 
GeneralRe: Help with Collections Pin
Heath Stewart22-Jan-04 18:49
protectorHeath Stewart22-Jan-04 18:49 
GeneralRe: Help with Collections Pin
crushinghellhammer22-Jan-04 19:32
crushinghellhammer22-Jan-04 19:32 
GeneralRe: Help with Collections Pin
Heath Stewart22-Jan-04 19:35
protectorHeath Stewart22-Jan-04 19:35 
GeneralRe: Help with Collections Pin
crushinghellhammer22-Jan-04 20:25
crushinghellhammer22-Jan-04 20:25 
GeneralRe: Help with Collections Pin
crushinghellhammer23-Jan-04 7:36
crushinghellhammer23-Jan-04 7:36 
GeneralRe: Help with Collections Pin
Heath Stewart23-Jan-04 8:21
protectorHeath Stewart23-Jan-04 8:21 
GeneralRe: Help with Collections Pin
crushinghellhammer23-Jan-04 7:44
crushinghellhammer23-Jan-04 7:44 
Questionhow to embed excel and pdf into winform ? Pin
Xpeive22-Jan-04 16:14
Xpeive22-Jan-04 16:14 
AnswerRe: how to embed excel and pdf into winform ? Pin
Heath Stewart22-Jan-04 18:42
protectorHeath Stewart22-Jan-04 18:42 
GeneralRe: how to embed excel and pdf into winform ? Pin
Xpeive23-Jan-04 16:34
Xpeive23-Jan-04 16:34 
GeneralRe: how to embed excel and pdf into winform ? Pin
Heath Stewart23-Jan-04 17:52
protectorHeath Stewart23-Jan-04 17:52 
GeneralRe: how to embed excel and pdf into winform ? Pin
Xpeive23-Jan-04 22:59
Xpeive23-Jan-04 22:59 
AnswerRe: how to embed excel and pdf into winform ? Pin
Guillermo Rivero23-Jan-04 1:27
Guillermo Rivero23-Jan-04 1:27 
GeneralCustom Component Functions Pin
obelisk2922-Jan-04 14:47
obelisk2922-Jan-04 14:47 
GeneralRe: Custom Component Functions Pin
Heath Stewart22-Jan-04 18:33
protectorHeath Stewart22-Jan-04 18:33 
GeneralRe: Custom Component Functions Pin
David Stone22-Jan-04 19:24
sitebuilderDavid Stone22-Jan-04 19:24 

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.