58808

Async generic delegate in C# 5.0

Question:

With Iterators, the following generic delegate is possible:

public delegate IEnumerable<TOut> MyDelegate<TIn>(TIn param1);

With the new async/await in C# 5.0 CTP, I expect to be able to create the analogous delegate as follows:

public delegate async TOut MyDelegate<TIn>(TIn param1);

I can't find the C# 5.0 spec or any help in this regard. Anyone know how this can be written or if it can't be written and why?

Thanks!

Answer1:

async is an implementation detail, not an interface specification. An async delegate doesn't make sense.

Any method that returns an "awaitable" (such as Task or Task<T>) can be used with await.

So an "asynchronous delegate" would be any delegate type that returns Task or Task<T> (or any other kind of awaitable). In your case:

public delegate Task<TOut> MyDelegate<TIn, TOut>(TIn param1);

Recommend

  • How to Create XUL Toolbar via Javascript?
  • What's the best way to asynchronously load data into a Data Grid View?
  • The same situation,Second time be rejected because of used MBProgressHUD :(
  • Does Vala support self-invoking?
  • Ruby 1.9 regular expression to match (un)?quoted key-value assignment
  • Error: 500 Can't connect to example.com:443 (certificate verify failed)
  • CakePHP theme resources return error
  • Child divs height isn't the same as parent div
  • VBA SelectSingleNode xpath with multiple namespace
  • Eclipse doesn't generate google cloud endpoint client library
  • send data from cakephp view to controller using $.ajax post
  • CakePHP & JQuery, location.reload sometimes not working
  • MySQL very slow query with custom function in spite of LIMIT
  • WP8 + Upload File to Skydrive
  • Display Current Video in Windows Phone 8 using AudioVideoCaptureDevice?
  • Get Users in Group from Azure AD via Microsoft Graph
  • use rvest and css selector to extract table from scraped search results
  • Using docker environment -e variable in supervisor
  • Nginx rewrite equivalent to Apache RewriteRule that converts URL params into QueryString key/value p
  • C# 4 and CLR Compatibility
  • Which browser have this strange user agent? (IOS device)
  • Varnish/Apache Random 503 Errors
  • is there a way to update filter with async data
  • Cuda Clang and OS X Mavericks
  • Authentication failed with Azure Active Directory in Windows Phone
  • In loopback documentation what does variable 'cb' stands for?
  • ThreadStatic in asynchronous ASP.NET Web API
  • Eloquent paginate function in Slim 3 project using twig
  • how to save the state in userdefaults of accessory checkmark-iphone
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Allowing both email and username for authentication
  • Getting 'uninitialized constant' error when using delegate in belongs_to in model
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Suggestions to manage Login/Logout transitions
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Bitwise OR returns boolean when one of operands is nil
  • MATLAB: Piecewise function in curve fitting toolbox using fittype