AsyncEx icon indicating copy to clipboard operation
AsyncEx copied to clipboard

Feature request: base class for event args

Open StephenCleary opened this issue 8 years ago • 2 comments

From @grokky1 on April 9, 2017 11:43

Many (in my experience, most) event handlers use event args without data. So this is boilerplate:

public class AsyncEventArgs : EventArgs, IDeferralSource
{
  internal DeferralManager DeferralManager { get; } = new DeferralManager();
  public IDisposable GetDeferral() => DeferralManager.DeferralSource.GetDeferral();
}

So would you kindly consider adding it to the library? Would make calling code mush cleaner.

If someone needs eventargs with data, then just subclass AsyncEventArgs. Which would also be cleaner.

Copied from original issue: StephenClearyArchive/AsyncEx.Oop#1

StephenCleary avatar Apr 21 '17 01:04 StephenCleary

Yes, absolutely! I just read a blog post last week where someone used a base class for this, and thought it would be a good idea.

The only real question is how the internal member should be exposed. Possibly keep it internal and just add event-raising helpers...

StephenCleary avatar Apr 21 '17 01:04 StephenCleary

From @grokky1 on April 9, 2017 12:11

I've only just started using your library so not sure. But to keep it simple, for now I've declared it as public.

StephenCleary avatar Apr 21 '17 01:04 StephenCleary