i have async method myactionasync
, receives parameter async func<int, task>
callback.
the method calls asynccallback correctly, steps on step before await
asyncallback have been executed.
this creates big problems me.
how / can use make sure await asynccallback(id)
step on when asynccallback has executed.
public class myservice { public async task<int> myactionasync(int id, func<int, task> asynccallback) { // 1. // 2. execute callback function // steps on step after first await finished, , not when of them finished await asynccallback(id); // 3. return return id; } } async task test() { func<int, task> asynccallback = async (id) => { var products = await _unitofwork.products.where(p => p.userid == id).tolistasync(); var pictures = await _unitofwork.pictures.where(p => p.userid == id).tolistasync(); }; myservice service = new myservice(); await service.myactionasync(1, asynccallback); }
the code seems ok
it should wait asynccallback finnished
how know not wait over?
maybe seems it's not waiting till it's on because debugger wont step func when press f11, step if put breakpoint inside
another thing should check if exception thrown inside func
Comments
Post a Comment