Welcome Guest Search | Active Topics | Sign In | Register

Best way to dispose of eo:WebControl Options
Brian
Posted: Monday, January 4, 2016 8:45:12 AM
Rank: Newbie
Groups: Member

Joined: 1/4/2016
Posts: 2
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!
eo_support
Posted: Monday, January 4, 2016 10:43:04 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

I do not need to do anything specifically to unload the WebView. The WebView is automatically destroyed after it has been taken off the visual tree. If the problem continues, you can try to update to the latest build and see if that resolves the issue for you. If that still does not resolve the issue for you, you can try to isolate the problem into a test project and send the test project to us. See here for more information about test project:

http://www.essentialobjects.com/forum/test_project.aspx

Thanks!
Brian
Posted: Tuesday, January 5, 2016 3:59:55 AM
Rank: Newbie
Groups: Member

Joined: 1/4/2016
Posts: 2
I solved it. It turned out to be a complicated threading issue not specifically related to your product.

Thanks for the quick support. This is a great product and I will certainly be buying it after a little more testing of the eval version.
eo_support
Posted: Tuesday, January 5, 2016 9:16:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Great. Glad that you hear that you found out the root cause. Please feel free to let us know if there is anything else.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.