Answer the question
In order to leave comments, you need to log in
C # - floating glitch - how correct was it?
There is a method:
private void Web_TitleChanged(object sender, TitleChangedEventArgs e)
{
Invoke(new Action(() => Text = e.Title));
}
private void Web_TitleChanged(object sender, TitleChangedEventArgs e)
{
if (!IsDisposed)
{
Invoke(new Action(() => Text = e.Title));
}
}
Answer the question
In order to leave comments, you need to log in
Subscribe to the FormClosing event (if not already subscribed) and, in its handler, unsubscribe from the TitleChanged, AddressChanged, LoadingStateChanged event handlers:
public partial class BrowserMain : Form
{
public BrowserMain()
{
InitializeComponent();
WebBrowser = new ChromiumWebBrowser(
string.IsNullOrWhiteSpace(address) ? "about:blank" : address)
{
// ...
};
Controls.Add(WebBrowser);
WebBrowser.TitleChanged += WebBrowser_TitleChanged;
WebBrowser.AddressChanged += WebBrowser_AddressChanged;
WebBrowser.LoadingStateChanged += webBrowser_DocumentCompleted;
}
private void BrowserMain_FormClosing(object sender, FormClosingEventArgs e)
{
// После вызова этих строк методы WebBrowser_TitleChanged, WebBrowser_AddressChanged
// и webBrowser_DocumentCompleted не будут выполняться.
// Это и не нужно, так как окно закрывается.
WebBrowser.TitleChanged -= WebBrowser_TitleChanged;
WebBrowser.AddressChanged -= WebBrowser_AddressChanged;
WebBrowser.LoadingStateChanged -= webBrowser_DocumentCompleted;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question