chromelyapps / Chromely

Build Cross Platform HTML Desktop Apps on .NET using native GUI, HTML5, JavaScript, CSS, Owin, AspNetCore (MVC, RazorPages, Blazor)
MIT License
2.99k stars 279 forks source link

When controller has async method task is not resolved properly #365

Closed michalpaukert closed 2 years ago

michalpaukert commented 2 years ago

When controller has async method task is not resolved properly

chromely version: 5.2.96

When I try to set any controller method as async it works until there is await something For example:

    [ChromelyRoute(Path = "/democontroller/movies/get")]
    public async Task<List<MovieInfo>> GetMovies()
    {
        await Task.Delay(1000);
        var movieInfos = new List<MovieInfo>();
        var assemblyName = typeof(MovieInfo).Assembly.GetName().Name ?? string.Empty;

        movieInfos.Add(new MovieInfo(id: 1, title: "The Shawshank Redemption", year: 1994, votes: 678790, rating: 9.2, assembly: assemblyName));
        movieInfos.Add(new MovieInfo(id: 2, title: "The Godfather", year: 1972, votes: 511495, rating: 9.2, assembly: assemblyName));
        movieInfos.Add(new MovieInfo(id: 3, title: "The Godfather: Part II", year: 1974, votes: 319352, rating: 9.0, assembly: assemblyName));
        movieInfos.Add(new MovieInfo(id: 4, title: "The Good, the Bad and the Ugly", year: 1966, votes: 213030, rating: 8.9, assembly: assemblyName));
        movieInfos.Add(new MovieInfo(id: 5, title: "My Fair Lady", year: 1964, votes: 533848, rating: 8.9, assembly: assemblyName));
        movieInfos.Add(new MovieInfo(id: 6, title: "12 Angry Men", year: 1957, votes: 164558, rating: 8.9, assembly: assemblyName));

        return movieInfos;
    }

An error occurs during message routing. With ur:/democontroller/movies/get. Response received:{"RequestId":"6ca7a4d4-aa3b-44a7-8778-ec1592a5aa79","ReadyState":4,"Status":400,"StatusText":"WaitingForActivation","Data":"WaitingForActivation\r\n","HasRouteResponse":false,"HasError":true,"Error":""}

michalpaukert commented 2 years ago

I proposed some changes in #367,

mattkol commented 2 years ago

I proposed some changes in #367,

Thanks for looking into this. I have not had bandwidth to look closely. I will test this out over the weekend.