Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webbrowser is not disposing itself

I am creating a WPF application. I created a usercontrol and put a back button and webbrowser. The webbrowser is for showing some Flash objects and works without a problem. However, when I click back, the program returns to previous user control but I can still hear some sound coming from webbrowser. Here is my method:

void btnClose_Click(object sender, RoutedEventArgs e)
{
    Content contentPage = new Content();
    webBrowser1.Dispose();
    this.Content = contentPage;
}

How can I dispose webbrowser? Thanks in advance

like image 244
Ercan Özdemir Avatar asked Dec 18 '25 23:12

Ercan Özdemir


1 Answers

Instead of calling Dispose, you should reset the WebBrowser.Source property:

webBrowser1.Source = null;
like image 100
Clemens Avatar answered Dec 21 '25 18:12

Clemens