c# - What is the return of Task? -
for past few weeks, have been looking @ tasks , struggled them. 1 of things have struggled creating awaitable method has no return type.
now non awaitable methods work this:
//this method return type: private string methodwithreturn() { return "this string return type"; } //this method without return type private void methodwithoutreturn() { //some random code has no return }
now when comes tasks, it's complicated. there 3 types: void
, task
, task<t>
void
not recommended @ all, left 2 tasks. here problem. want have task without return type , code:
private task tasktypemethod() { //some random code }
the issue here still issues warning "not code paths return value". understanding tasks incorrectly or doing wrong here?
i told add async
before it, requires me use await
keyword inside code block, won't using.
without returning task
, how caller find out when async computation presumably running completed? if nobody needs know, make method return task
, have return value ignored. if not possible reason can use async void
.
how generate task
return not important know callers. easy way make method async task
.
the issue here still issues warning "not code paths return value".
well, error makes sense. promise return don't. can't work. either hold of task
, return or use async task
. maybe need find out async
means.
Comments
Post a Comment