G
Guest
Using lock(this) has been much maligned since someone external to your object
can lock causing possible deadlock and forcing you to now create an extra
object lock_=new object(); in any classes using locking with nothing better
to lock on.
How about supporting a protected property on System.Object as SyncObj (so it
is really an internal locking object rather than this object) or something
like that that can be locked on. Perhaps the C# can be changed to support
the following:
lock
{
//...
}
With no arguments to lock it would by default use the protected SyncObj.
This will make C#.NET threading safer and easier.
can lock causing possible deadlock and forcing you to now create an extra
object lock_=new object(); in any classes using locking with nothing better
to lock on.
How about supporting a protected property on System.Object as SyncObj (so it
is really an internal locking object rather than this object) or something
like that that can be locked on. Perhaps the C# can be changed to support
the following:
lock
{
//...
}
With no arguments to lock it would by default use the protected SyncObj.
This will make C#.NET threading safer and easier.