Dear Mr. Tang,
Thanks very much for the detailed information. But as far as I know, the
Application.Exi t 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.Exi t event handle, it goes into the dispatcher timer's
Tick event handle immediately. But after that, both of the IExplorer.exe
and the PresentationHos t.exe process quit correctly. I did not see the
PresentationHos t.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()
{
InitializeCompo nent();
}
void Current_Exit(ob ject sender, ExitEventArgs e)
{
Debug.Print("Ap plication Exited");
}
private void Page_Loaded(obj ect sender, RoutedEventArgs e)
{
AppDomainSetup domaininfo = new AppDomainSetup( );
domaininfo.Appl icationBase =
AppDomain.Curre ntDomain.BaseDi rectory;
Application.Cur rent.Exit += new ExitEventHandle r(Current_Exit) ;
AppDomain newDomain = AppDomain.Creat eDomain("NewDom ain", null,
domaininfo);
MarshalByRefTyp e mbrt =
newDomain.Creat eInstanceAndUnw rap(Assembly.Ge tExecutingAssem bly().FullName,
"WpfBrowserAppl ication1.Marsha lByRefType") as MarshalByRefTyp e;
mbrt.SetTimer() ;
}
}
public class MarshalByRefTyp e : MarshalByRefObj ect
{
public void SetTimer()
{
System.Windows. Threading.Dispa tcherTimer timer = new
System.Windows. Threading.Dispa tcherTimer();
timer.IsEnabled = true;
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += new EventHandler(ti mer_Tick);
}
void timer_Tick(obje ct sender, EventArgs e)
{
Debug.Print("Ti mer 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,
v-****@microsoft. com.
Thanks for your cooperation and have a nice day, Steven!
Best regards,
Ji Zhou (v-****@online.mic rosoft.com, 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:
ms****@microsof t.com.
This posting is provided "AS IS" with no warranties, and confers no rights.