What's the best way to dispose of a WebControl?
I have a WPF UserControl hosting a WebControl.
Code: HTML/ASPX
<UserControl x:Class="MyClass"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:eo="http://schemas.essentialobjects.com/wpf/"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Unloaded="UserControl_Unloaded" >
<Grid>
<eo:WebControl Name="webControl1" Grid.Column="0" Visibility="Visible">
<eo:WebControl.WebView>
<eo:WebView LoadCompleted="WebView_LoadCompleted" NewWindow="WebView1_NewWindow">
</eo:WebView>
</eo:WebControl.WebView>
</eo:WebControl>
</Grid>
</UserControl>
In the Unloaded event of the User Control I have:
Code: C#
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
if(this.webControl1.WebView != null){ this.webControl1.WebView.Dispose();}
GC.Collect();
GC.WaitForPendingFinalizers();
}
But the program is not terminating cleanly. In design mode (not tested live yet) the 'stop' icon is still active after the program is 'stopped'.
The Unloaded event is executing.
Am I missing something please?
Thanks!