C# After changing Generic to Async , How to resolve this error ? Task<T> -


i used extention await task command.

public static async task<t> getcompletedtask<t>(this t command) t : commandbase     {         var tcs = command.gettaskcompletionsource();         await tcs.task.configureawait(false);         return command;     } 

here example use.

var result = await class.gorun(1).getcompletedtask(); 

method "gorun" made generic.

public t gorun<t>(int runnderid)         t : commandbase 

....

but have change "gorun" async... because want use await in gorun. change this.

public async task<t> gorun<t>(int runnderid)         t : commandbase 

....

after modification. "getcompletedtask" generate error.

how should modify (getcompletedtask) ?

here error message.( translated japanese english )

'system.threading.tasks.task<bg7uwp1.commands.device.serialconnectcommand>' can not use t in generic type or method 'commandextensions.getcompletedtask<t>(t)' there no "implicit reference conversion" 'system.threading.tasks.task<bg7uwp1.commands.device.serialconnectcommand>' 'bg7uwp1.commands.commandbase' bg7uwp1  

in idea, have modify "getcompletedtask". wrote bit.. no idea...

enter image description here

based on little bit of code have shared, need change call site await both gorun() method , getcompletedtask() method:

var result = await (await class.gorun(1)).getcompletedtask(); 

that is, first need await result of gorun(1), , need pass result getcompletedtask(), await.

now, want? don't know. don't have enough code in question, never mind minimal, complete, , verifiable code example illustrates scenario. if above doesn't solve problem satisfactorily, please improve question.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -