U
U
Uncle Bogdan2021-06-07 22:40:41
C++ / C#
Uncle Bogdan, 2021-06-07 22:40:41

Why did browser.FrameLoadEnd stop working properly?

Like before, everything was more or less normal, it worked 2 times (at the beginning and end of the download) and normally, but now it only works at the beginning, when the html is empty. What's wrong?

public Form1()
        {
            InitializeComponent();
            InitializeChromium();

            browser.FrameLoadEnd += WebBrowserFrameLoadEnded;
        }


        private void WebBrowserFrameLoadEnded(object sender, FrameLoadEndEventArgs e)
        {

            Task.Run(async () => html = await browser.GetSourceAsync());


            MessageBox.Show(html); // html = null
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-06-07
@motkot

Task.Run(async () => html = await browser.GetSourceAsync());
            MessageBox.Show(html); // html = null

You didn't wait for the download to finish.
Try to make the handler async void and do this:
html = await browser.GetSourceAsync()
MessageBox.Show(html);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question