List Info

Thread: Threading




Threading
user name
2006-11-22 21:44:49
> I've found doing
>
> object objectForLocking = new object();
>
> to be no major hassle to avoid the entire mess.

+1.

AND if you  need a string key (like for a cache-dependancy
key or
something), I suggest

string objectForLocking = Guid.NewGuid.ToString();

--
"Statistics do not apply to anyone, however they do
apply to everyone."
Marc C. Brooks
http://musingmarc.blog
spot.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Threading
user name
2006-11-22 22:26:23
Marc Brooks wrote:
>> to be no major hassle to avoid the entire mess.
>
> +1.
>
> AND if you  need a string key (like for a
cache-dependancy key or
> something), I suggest
>
> string objectForLocking = Guid.NewGuid.ToString();

The only downside with both of these is that they don't make
it obvious
from the type itself that the purpose is for locking. That's
one of the
reasons I created a class specifically for locking. Even
without any
extra functionality (i.e. using it just as a reference) I
think there'd
be some point in having a class Lock (or whatever) which
could
optionally take a name. It makes it incredibly obvious what
it's there for.

Jon

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )