Dear Mr. Tang,
Thanks very much for the detailed information. But as far as I know, the
Application.Exit is the only reliable event that fires when we close the
web browser directly. And from my current research, the issue may not be
related to the dispatcher timer. Detail goes as follows,
I am trying to reproduce the issue but still cannot in my side. Currently,
I am using the following codes to simulate your described scenario. It
firstly creates a new AppDomain and from that AppDomain, I set a 1s
dispatcher timer. As you said, I can also see that after the codes returns
from the Application.Exit event handle, it goes into the dispatcher timer's
Tick event handle immediately. But after that, both of the IExplorer.exe
and the PresentationHost.exe process quit correctly. I did not see the
PresentationHost.exe remain in the memory in my side. Consequently, I think
the issue may cause from other parts of codes. It will not be fixed even we
stop the dispatcher timer.
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
void Current_Exit(object sender, ExitEventArgs e)
{
Debug.Print("Application Exited");
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ApplicationBase =
AppDomain.CurrentDomain.BaseDirectory;
Application.Current.Exit += new ExitEventHandler(Current_Exit);
AppDomain newDomain = AppDomain.CreateDomain("NewDomain", null,
domaininfo);
MarshalByRefType mbrt =
newDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName,
"WpfBrowserApplication1.MarshalByRefType") as MarshalByRefType;
mbrt.SetTimer();
}
}
public class MarshalByRefType : MarshalByRefObject
{
public void SetTimer()
{
System.Windows.Threading.DispatcherTimer timer = new
System.Windows.Threading.DispatcherTimer();
timer.IsEnabled = true;
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += new EventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
Debug.Print("Timer Ticked");
}
}
For future investigation into this issue, I firstly need to reproduce it in
my side. Thus, would you like to share a mini project that can show the
problem? You can send it to me at this email address, (e-mail address removed).
Thanks for your cooperation and have a nice day, Steven!
Best regards,
Ji Zhou (
[email protected], remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
This posting is provided "AS IS" with no warranties, and confers no rights.