New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long Running Data-Get blockted UI #1786

Closed
UrielMhezzek opened this Issue Feb 10, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@UrielMhezzek
Copy link

UrielMhezzek commented Feb 10, 2019

Info about the project:

  • Blazor Server-side Project

I tried with simulate long running to get Data from Database with the Forecast Example. If I switch to the side, then blazor hangs for time. Can this be avoided?

public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
       {
           TaskHelper.BusyWait(3000);
           var rng = new Random();
           return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
           {
               Date = startDate.AddDays(index),
               TemperatureC = rng.Next(-20, 55),
               Summary = Summaries[rng.Next(Summaries.Length)]
           }).ToArray());
       }
[...]
public static void BusyWait(int milliseconds)
       {
           var sw = Stopwatch.StartNew();

           while (sw.ElapsedMilliseconds < milliseconds)
               Thread.SpinWait(1000);
       }
@xclud

This comment has been minimized.

Copy link

xclud commented Feb 10, 2019

GetForecastAsync and BusyWait must be async.

public async Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
       {
           await Task.Delay(3000);  //TaskHelper.BusyWait(3000);
           //Change above line to call a version of BusyWait which is async.

           var rng = new Random();
           return Enumerable.Range(1, 5).Select(index => new WeatherForecast
           {
               Date = startDate.AddDays(index),
               TemperatureC = rng.Next(-20, 55),
               Summary = Summaries[rng.Next(Summaries.Length)]
           }).ToArray();
       }

BTW, Please do not post here. This repository is for Blazor infrastructure. Please read this: https://github.com/aspnet/Blazor/blob/master/README.md

@danroth27

This comment has been minimized.

Copy link
Member

danroth27 commented Feb 11, 2019

This issue was moved to aspnet/AspNetCore#7463

@aspnet aspnet locked and limited conversation to collaborators Feb 11, 2019

@danroth27 danroth27 closed this Feb 11, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.