O
ormico
I have a small WPF application that has a frame that points to a web page on
the internet.
<Window x:Class="WpfWebBrowser.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="800" Width="1118" WindowState="Maximized">
<Grid Name="grMain">
<Frame Name="frmDisplay" NavigationUIVisibility="Visible"
Margin="0,0,0,50" Source="http://example.com/" />
<Button Name="btRefresh" Width="100" Height="32"
Click="btRefresh_Click" HorizontalAlignment="Left" Margin="12,0,0,12"
VerticalAlignment="Bottom">0</Button>
<Button Name="btClose" Width="100" Height="32" Click="btClose_Click"
HorizontalAlignment="Left" Margin="118,0,0,12"
VerticalAlignment="Bottom">Close</Button>
</Grid>
</Window>
I also have a System.Timer.Timer that goes off after 1 minute. If I try to
modify an object on the page it generates an error and crashes the program.
This is an error that I cannot catch with a try catch block. It crashes the
program anyway and prompts me to send the crash info to microsoft.
If I remove the Frame, no error is generated.
public Window1()
{
InitializeComponent();
timer2 = new System.Threading.Timer(timer2_Callback);
timer2.Change((int)(TimeSpan.FromMinutes(1.0).TotalMilliseconds), 0);
}
void timer2_Callback(object state)
{
this.Dispatcher.Invoke((Action)(delegate()
{
btRefresh.Content = "blah";
}));
}
What I am ultimatly try to accomplish is an application that displays a web
page for a certain amount of time, then closes. I would like to put this in
an appdomain that gets reloaded after it closes each time. This is because
when the web page runs for a while in IE it will consume more and more
memory. I want to be able to unload the page wit the web browser control to
free the memory and then reopen and go back to the page. Most of this is
working but I can't get the wpf page with the webbrowser control to close
after a certain amount of time because when I call this.Close() or
Application.Current.Shutdown() it crashes. I get the same behavior if I try
to access any other controls also.
the internet.
<Window x:Class="WpfWebBrowser.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="800" Width="1118" WindowState="Maximized">
<Grid Name="grMain">
<Frame Name="frmDisplay" NavigationUIVisibility="Visible"
Margin="0,0,0,50" Source="http://example.com/" />
<Button Name="btRefresh" Width="100" Height="32"
Click="btRefresh_Click" HorizontalAlignment="Left" Margin="12,0,0,12"
VerticalAlignment="Bottom">0</Button>
<Button Name="btClose" Width="100" Height="32" Click="btClose_Click"
HorizontalAlignment="Left" Margin="118,0,0,12"
VerticalAlignment="Bottom">Close</Button>
</Grid>
</Window>
I also have a System.Timer.Timer that goes off after 1 minute. If I try to
modify an object on the page it generates an error and crashes the program.
This is an error that I cannot catch with a try catch block. It crashes the
program anyway and prompts me to send the crash info to microsoft.
If I remove the Frame, no error is generated.
public Window1()
{
InitializeComponent();
timer2 = new System.Threading.Timer(timer2_Callback);
timer2.Change((int)(TimeSpan.FromMinutes(1.0).TotalMilliseconds), 0);
}
void timer2_Callback(object state)
{
this.Dispatcher.Invoke((Action)(delegate()
{
btRefresh.Content = "blah";
}));
}
What I am ultimatly try to accomplish is an application that displays a web
page for a certain amount of time, then closes. I would like to put this in
an appdomain that gets reloaded after it closes each time. This is because
when the web page runs for a while in IE it will consume more and more
memory. I want to be able to unload the page wit the web browser control to
free the memory and then reopen and go back to the page. Most of this is
working but I can't get the wpf page with the webbrowser control to close
after a certain amount of time because when I call this.Close() or
Application.Current.Shutdown() it crashes. I get the same behavior if I try
to access any other controls also.