c# - How to await async method inside ExecutePostProcessingAsync -


i use code http://arcware.net/upload-and-download-files-with-web-api-and-azure-blob-storage/ upload blobs azure. method executepostprocessingasync() call method resizes images , uses async code.

the method want use in looks(shrinked) this:

            public override task executepostprocessingasync()             {               //some code                 //i await image resizer method here before going further               resizer.scaleimage();               //some more code here before returning              return base.executepostprocessingasync();             } 

if add async method this: public override async task executepostprocessingasync()

5+ errors pop reference issues , error:

"is async method returns 'task', return keyword must not followed object expression. did intend return 'task'?"

questions:

is there anyway await method inside method? or input appreciated, thanks!

the async keyword enables use of await keyword. said, correct syntax not return task represents operation, rather await it. consider following:

public override async task executepostprocessingasync() {     await resizer.scaleimageasync();     await base.executepostprocessingasync(); } 

notice how instead of trying return task represents base execution, i.e.; base.executepostprocessingasync() await instead.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -