Declaring async in interfaces


i've red quite lot of documentation , played around samples, can't remeber coming across use of async in interfaces. of course, might not necessary when showing off new concept, since love interfaces i'd make comment them in regards async.

  public interface itestasync  {    async task<string> dosomething();  }  

the code above works fine static checker, cannot compile , gives following errors:
- async modifier can used in methods have statement body
- modifier 'async' not valid item

i think being able make use of "async" in interface needed in order ensure consistency. through use of "task" return type argue method indirectly can identified async, might not true in case , of course doesn't work "void"-methods. lead inconsistent implmentations of interfaces. naming conventions might on it's expect able enforce compilerwise.

currently static checker accepts async-decorated interface-methods return types other task show below

  public interface itestasync  {    async string dosomething();  }  

if "async" not have place in interfaces must bug in static checker. (static checker in classes reports error intended)

 

to make question i'd ask team view on "async" in interfaces? :-)

re: "it on other hand make intentions clear, iasyncresult."

task , task<tresult> representations of on-going / asynchronous operations.  if method returns task/task<tresult>, it's saying complete @ point in future (i.e. it's asynchronous), , task can used handle refer , join operation.  alluded in previous resposne, async keyword implementation; there many ways implement method asynchronous, , don't need await , async keywords it... make much, easier (and correctly) in many cases.

in short, returning task or task<tresult> should make intention clear.

thanks feedback.



Archived Forums V  >  Visual Studio Async CTP



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'