async await - Return Task<int> from int member C# best practice -


i have member of type int in class.
expose class task function return member.

int _somemember; 

i know can do:

public int returnthemember() { return _somemember; } 

but class function must task based.

is possible wrap call in task ? like:

    public async task<int> returnthemember()     {         await task.fromresult(0);         return _somemember;     } 

notice - must task.fromresult(0) because treat warning errors - wont compile since method async on signature must contain "await".

i know if pattern used. or wrong doing so.

you don't need async @ all.

just create normal method , call task.fromresult() create synchronously-resolved task result.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -