For my Web Browser, I need a way to show if a page is loading. So I used this code
private void ChromiumWebBrowser1_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
{
if (bunifuCards1.Contains(bunifuLoader1))
{
if (e.IsLoading)
{
bunifuLoader1.BringToFront();
}
else
{
bunifuImageButton4.BringToFront();
}
}
}
But it gave me this error on bunifuLoader1.BringToFront();
System.InvalidOperationException: 'Cross-thread operation not valid: Control 'bunifuLoader1' accessed from a thread other than the thread it was created on.'
This exception was originally thrown at this call stack:
System.Windows.Forms.Control.Handle.get()
System.Windows.Forms.Control.UpdateChildZOrder(System.Windows.Forms.Control)
System.Windows.Forms.Control.UpdateZOrder()
System.Windows.Forms.Control.ControlCollection.SetChildIndexInternal(System.Windows.Forms.Control, int)
System.Windows.Forms.Control.ControlCollection.SetChildIndex(System.Windows.Forms.Control, int)
System.Windows.Forms.Control.BringToFront()
World_Search_8_Goldsmith.frmBrowser.ChromiumWebBrowser1_LoadingStateChanged(object, CefSharp.LoadingStateChangedEventArgs) in frmBrowser.cs
CefSharp.WinForms.ChromiumWebBrowser.CefSharp.Internals.IWebBrowserInternal.SetLoadingStateChange(CefSharp.LoadingStateChangedEventArgs) in ChromiumWebBrowser.Partial.cs
CefSharp::Internals::ClientAdapter::OnLoadingStateChange(scoped_refptr<CefBrowser>*, bool, bool, bool) in ClientAdapter.cpp
Can some plz help me