MethodBoundaryAspect.Fody icon indicating copy to clipboard operation
MethodBoundaryAspect.Fody copied to clipboard

How to make the asynchronous OnEntry method execute after the execution of the decorated method?

Open CodingOctocat opened this issue 4 years ago • 1 comments

I found that if the OnEntry method is asynchronous, it will run alternately with the decorated method, which is not the result I want, and I want OnEntry to be executed in its entirety first.

public class AutoGetAccessToken : OnMethodBoundaryAspect
{
    public override async void OnEntry(MethodExecutionArgs arg)
    {
        await RequestOrRefreshAccessTokenAsync();
    }
}

[AutoGetAccessToken]
public async Task<Repo> GetFileAsync()
{
    // ...
}

CodingOctocat avatar Nov 02 '21 12:11 CodingOctocat

Unfortunately we don't support this. Your method "GetFileAsync" runs concurrent because there is no Task returned from "OnEntry" so nobody is awaiting the call.

Ralf1108 avatar Nov 10 '21 08:11 Ralf1108