473,670 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XBAP page unload

It seems that one page XBAP whose Unloaded event
never get called, I need put some clearing stuff (I.G stop dispatcher time)
when
user close browser, it unload event doesn't work, where
shall I put?

--
=============== ========
Steven Tang
SYWWUYU)
**:)
Nov 10 '08 #1
5 5893
Hello Steven Tang,

Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou
[MSFT] and I will be working on this issue with you.

I have a quick test on my side as follows, and can reproduce the issue when
I directly close the web browser.

In the .xaml file,
<Page x:Class="WpfBro wserApplication 1.Page1"
xmlns="http://schemas.microso ft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microso ft.com/winfx/2006/xaml"
Title="Page1" Unloaded="Page_ Unloaded">
<Grid>
</Grid>
</Page>

In the Page1.xaml.cs,
private void Page_Unloaded(o bject sender, RoutedEventArgs e)
{
MessageBox.Show ("Test");
}

But when I press F5 to refresh the XBAP page, the Page's unload event fires
correctly. That is to say, this event will only fires when the embedded wpf
page gets unloaded and the Web Browser remains open. In my opinion, when
we close the web browser directly, the whole XBAP application will shut
down and the resource will be cleaned up automatically. I think it is not
necessary to stop the dispatcher timer there? Could you please clarify what
exactly you want to do in the Unload event handle? So that we can try to
provide a future suggestion on an specific scenario.

And based on my research on the web, I found the following discussion in
the MSDN WPF Forum. We can see that another two possible workarounds will
be Application.Exi t and the IProvideCustomC ontentState. Codes in these
event handler or function are guarantee to be called.
http://social.msdn.microsoft.com/For...5f5-43ca-4b1c-
9b54-d74b727f8e12/

Please let me know if these suggestions fit your scenario.

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.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 11 '08 #2
Hello Mr Zhou,
Thanks for response, actually I tried the Application.Exi t and it
didn't work,
IProvideCustomC ontentState doesn't work either.
My concern to this issue is that
1. When I close the browser, there will be a PresentationHos t.exe
corpse
left in the Task Manager every time when I run the XBAP, If I run multiple
time,
multiple PresentationHos t.exe in the Task Manager, they will not release the
resource.
2. My XBAP load one dll and the dll do sth. I have an 1s timer in
the XBAP to check the background status, I added the unload dll code in the
AppEXit methods we mentioned, and I debugged into the code, after traced
through the AppExit code, the application will go back to the timer handler
and this cause that even I closed the browser, there still be an corp left @
task manager until I manually kill it from task manager.
3. If I could know the event of the page closed, I can stop the
timer first so that the process will not go back to xbap code and this shall
be able to fix the corpse issue.
4. Any other event indicates that browser is closing?

Best Regards
--
=============== ========
Steven Tang
SYWWUYU)
**:)
"""Ji Zhou [MSFT]""" wrote:
Hello Steven Tang,

Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou
[MSFT] and I will be working on this issue with you.

I have a quick test on my side as follows, and can reproduce the issue when
I directly close the web browser.

In the .xaml file,
<Page x:Class="WpfBro wserApplication 1.Page1"
xmlns="http://schemas.microso ft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microso ft.com/winfx/2006/xaml"
Title="Page1" Unloaded="Page_ Unloaded">
<Grid>
</Grid>
</Page>

In the Page1.xaml.cs,
private void Page_Unloaded(o bject sender, RoutedEventArgs e)
{
MessageBox.Show ("Test");
}

But when I press F5 to refresh the XBAP page, the Page's unload event fires
correctly. That is to say, this event will only fires when the embedded wpf
page gets unloaded and the Web Browser remains open. In my opinion, when
we close the web browser directly, the whole XBAP application will shut
down and the resource will be cleaned up automatically. I think it is not
necessary to stop the dispatcher timer there? Could you please clarify what
exactly you want to do in the Unload event handle? So that we can try to
provide a future suggestion on an specific scenario.

And based on my research on the web, I found the following discussion in
the MSDN WPF Forum. We can see that another two possible workarounds will
be Application.Exi t and the IProvideCustomC ontentState. Codes in these
event handler or function are guarantee to be called.
http://social.msdn.microsoft.com/For...5f5-43ca-4b1c-
9b54-d74b727f8e12/

Please let me know if these suggestions fit your scenario.

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.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 11 '08 #3
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.

Nov 12 '08 #4
Hi Mr.Zhou,
Sorry that I didn't response for couple days due to that I was busy on
other stuff, and thanks a lot that you spent time on recreating the cases.
I tried to debug into my code, after I close the browser, to code will
go to
AppExit, and after the AppExit, the code will go to timer handler, if I
disable
all the break ponters and press the continue, after I close the browser, the
debug will not stop and nothing shows on Call Stack, and I clicked on the
break all, the call stack will be:
> ntdll.dll!KiFas tSystemCallRet( )
[Frames below may be incorrect and/or missing, no symbols loaded for
ntdll.dll]
ntdll.dll!NtWai tForMultipleObj ects() + 0xc bytes
user32.dll!Tran slateMessageEx( ) + 0x172 bytes
ole32.dll!CoGet PSClsid() + 0x154 bytes
ole32.dll!CoGet PSClsid() + 0x2b4 bytes
ole32.dll!WdtpI nterfacePointer _UserUnmarshal( ) + 0x1c6 bytes
ole32.dll!WdtpI nterfacePointer _UserUnmarshal( ) + 0x11bb bytes
ole32.dll!WdtpI nterfacePointer _UserUnmarshal( ) + 0x1027 bytes
ole32.dll!CoGet PSClsid() + 0x35a bytes
ole32.dll!CoGet PSClsid() + 0x30c bytes
ole32.dll!CoReg isterSurrogateE x() + 0x3b9c bytes
rpcrt4.dll!NdrP roxySendReceive () + 0x43 bytes
rpcrt4.dll!NdrP roxySendReceive () + 0xa4 bytes
rpcrt4.dll!NdrC lientCall2() + 0x764 bytes
rpcrt4.dll!I_Rp cGetBufferWithO bject() + 0xb7 bytes
ole32.dll!ReadC lassStm() + 0xdad bytes
ole32.dll!ReadC lassStm() + 0xd5f bytes
ole32.dll!CoReg isterSurrogateE x() + 0x2a43 bytes
ole32.dll!CoReg isterSurrogateE x() + 0x291a bytes
ole32.dll!CoReg isterSurrogateE x() + 0x27c1 bytes
ole32.dll!CoReg isterSurrogateE x() + 0x272b bytes
ole32.dll!CoReg isterSurrogateE x() + 0x2678 bytes
rpcrt4.dll!IUnk nown_Release_Pr oxy() + 0x13 bytes
PresentationHos tDLL.dll!Create IDispatchSTAFor warder() + 0x1cd6 bytes
and I clicked on the continue again, the code will keep going and just
won't get out. The only way I to stop the debugging session is to hit the
Stop Debugging button.
According your experience, if the XBAP will not clear
PresentationHos t.exe
after closed the browser, and the PageUnload could not be called, how to fix
this
issue?

Best Regards

--
=============== ========
Steven Tang
SYWWUYU)
**:)
"""Ji Zhou [MSFT]""" wrote:
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.

Nov 16 '08 #5
Hello Mr. Tang,

To do future investigation, I firstly need to reproduce the issue in my
side. It is really hard to guess the problem without seeing your other
parts of codes. Would you mind sending me a mini reproducible project, or
posting the codes in your timer tick event here? Thanks for your
understanding.

Have a good day!

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.

Nov 17 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4116
by: MMA | last post by:
Can an WBA/XBAP directly make a call to database server or does it need to go through the WS? Thanks in Advanec
5
2678
by: dgk | last post by:
From what I've been reading, an XBap application could be really good for a place like mine where everyone will have a PC that has framework 3 loaded and runs IE. The app is downloaded from a server but runs in the browser, hosted by PresentationHost.exe. So, since it gets the app from the server each time that it runs (yes?) it makes maintenance easy. But because it isn't a bunch of html and javascript but can access almost the full...
2
4259
by: Abhi Arora | last post by:
Hi, I need to host an XBAP application inside an Aspx page. I tried adding my aspx page using IFRAME, but it doesnt show up in the browser. When I call the page, it runs without any error. But it doesnt show anything from the XBAP page. Am I missing something simple here? Abhi
0
3020
by: Masudur | last post by:
Hi, I been searching net for a while for solution but unable to work. i have few questions regarding xbap applicaion. first of all can i really use wcf service with xbap browser application in partial trust that is in internet. if i can please help me with some specific guide line. second of all how can i communicate with the parent site... from xbap. that is if my xbap is hosted in http://mysite/app/default.aspx page in a iframe
3
3604
by: =?Utf-8?B?SXpvcmljaA==?= | last post by:
I observed that WCF client running inside Full Trust mode XBAP application can't read byte array over 16384. If return result is bigger than that size, then client simply get null or Nothing in VB and there are no exceptions. I have tried increasing limits on both client and server. Here is a typical entry: <binding name="myBasicHttpBinding" maxBufferSize="2097152" maxBufferPoolSize="8388608" maxReceivedMessageSize="2097152"...
2
3154
by: Steven Tang | last post by:
It seems that we can only embed XBAP Iframe to create a WPF gadget, the WPF application will not work at this time (I tried Stanimir's demo, it is not different to a standalone WPF application, it will not be able to dock into the sidebar when move the "Hello gadget" closing to the sidebar, I don't know if it is still a sidebar gadget if it could not dock into the sidebar). The problem I met in XBAP gadget is that it is difficult to set...
0
1464
by: | last post by:
It seems that we can only create a WPF gadget by embed XBAP Iframe, the WPF application will not work at this time (I tried Stanimir's demo, it is not different to a standalone WPF application, it will not be able to dock into the sidebar when move the "Hello gadget" closing to the sidebar, I don't know if it is still a sidebar gadget if it could not dock into the sidebar). The problem I met in XBAP gadget is that it is difficult to set...
2
11304
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
I'm creating a XBAP application and want it take some input from webpage dynamically? what is the best way? how to do it? Best Regards Steven -- ======================= Steven Tang SYWWUYU)
4
2942
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
I'm creating WPF gadget by embed XBAP Iframe: 1. Is it possible that create Pure WPF (non-XBAP) which could auto dock into the Vista sidebar when dragging the WPF application near Sidebar? 2. My current approach is using XBAP inside the iFram, The problem I met in XBAP gadget is that it is difficult to set padding so that the gadget could be drag out of the sidebar. I.E., the size of my XBAP is 190X145, my html launcher is <html>
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5686
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.