Thanks for the feedback.
"Jon Skeet [C# MVP]" wrote:
> steve <(E-Mail Removed)> wrote:
> > Don't know if this is the correct forum for this, but here goes..
> >
> > - independent access level modifiers for property get and set members
> > eg. public get, protected set, set provides validation / thread sync
> > facilities
>
> That's already in the beta.
>
good
> > - default class member access set to protected rather than private
>
> Thankfully that's *not* in the beta. Protected access should be used
> more rarely than private access (particularly for fields). In addition,
> if you make something private but it should actually be protected,
> you're likely to find out at compile time. The other way round, you'll
> never know until something uses the unintended access...
>
fair enough for fields. But invariably I find that I want to call methods
of ancestors. Yes I agree that it is best to encapsulate as much as
possible, I guess it's just a bit harder when your in a hurry.. ; )
> > - automagic thread concurrency managment for the add / remove event members
> > eg. automagic management of thread concurrency issues associated with +=
> > and -= event overloads
>
> What exactly would you want it to do? Currently it locks on "this" and
> I believe it will at least be *allowed* to lock on a private member
> variable instead if the compiler decides to.
>
I googled up this commentary on event race conditions
http://blogs.msdn.com/csharpfaq/arch.../19/93082.aspx
This is what I have been doing to avoid probs when wiring / unwiring
delegates. comments?
#region SomethingHappenedEvent
object SomethingHappenedEventLock = new object();
protected event SomethingHappenedEvent mSomethingHappened;
public event SomethingHappenedEvent SomethingHappened
{
add
{
lock (SomethingHappenedEventLock)
{
if (mSomethingHappened == null)
{
// Acquire any shared resources required for processing event
}
mSomethingHappened += value;
}
}
remove
{
lock (SomethingHappenedEventLock)
{
mSomethingHappened -= value;
if (mSomethingHappened == null)
{
// Release any shared resources required for processing event
}
}
}
}
protected virtual void OnSomethingHappened()
{
lock (SomethingHappenedEventLock)
{
if (mSomethingHappened != null)
{
mSomethingHappened(this, new SomethingHappenedEventArgs());
}
}
}
#endregion
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> If replying to the group, please do not mail me too
>