草庐IT

FooAsync

全部标签

c# - 当我在接口(interface)方法调用中忘记 `await` 时没有警告

考虑:usingSystem.Threading.Tasks;classProgram{staticvoidMain(string[]args){Cc=newC();c.FooAsync();//warningCS4014:Becausethiscallisnotawaited,executionofthecurrentmethodcontinuesbeforethecalliscompleted.Considerapplyingthe'await'operatortotheresultofthecall.((I)c).FooAsync();//Nowarning}}classC:I{

c# - 当我在接口(interface)方法调用中忘记 `await` 时没有警告

考虑:usingSystem.Threading.Tasks;classProgram{staticvoidMain(string[]args){Cc=newC();c.FooAsync();//warningCS4014:Becausethiscallisnotawaited,executionofthecurrentmethodcontinuesbeforethecalliscompleted.Considerapplyingthe'await'operatortotheresultofthecall.((I)c).FooAsync();//Nowarning}}classC:I{