Presuming you have an email folder and messages in it. Each message has Body property, which needs to be loaded async and notify you when done, how would you approach this?
1 – Message.LoadBody() + event Message.BodyLoadComplete
2 – Message.LoadBody(Action completeDelegate)
For the sake of completeness WPF and Prism are involved.
Thanks!
Edit:
Message will be a UI entity which will wrap a IMessage interface (that is not UI Ready (no INPC)), so the reason i’m asking is that we have to settle for an interface between UI and business layer.. IMessage. (The Business layer will be using an Imap library that already has some async pattern, but we don’t want to depend too much on any imp, thats why i’m trying to figure out the best interface ..
If you’re using .NET 4, I’d use:
(You might want to implement this using
TaskCompletionSource<TResult>.)The caller can then add continuations etc however they wish… and most importantly, in the brave new world of .NET 4.5 and C# 5, this will work seamlessly with the
async/awaitfeatures.