C#C
C#15mo ago
Bubba

Async issue

Hi! I'm trying to perform an http get request in a graphical element of the Eto library. Thing is, my whole program freezes until the response is received and I'm unsure why.

...REST OF THE CODE...
public class Body : StackLayout
{
    public Body()
    {
        Orientation = Orientation.Vertical;
        Padding = 10;
        Spacing = 10;

        var label = new Label
        {
            Text = "Home page loading...",
            Font = new Font(FontFamilies.Sans, 16),
            VerticalAlignment = VerticalAlignment.Center
        };

        Task.Run(async () => await LoadHomePageAsync(label)));
    }

    private async Task LoadHomePageAsync(Label label)
    {
        var content = await RetrieveHomePageContentAsync();
        label.Text = content;
    }


The call is performed inside the Task.Run, did I do something wrong?
Was this page helpful?