I just published a new article showing how to implement a clean shutdown sequence in a Silverlight and WPF application. The sample app uses the MVVM Light Toolkit Messenger, but of course this could also be implemented with other kind of messengers.
I have been confronted to this kind of issues in production applications in the past, with a lot of components having to shut down in a coordinated manner, and I think that having a decoupled messenger makes that issue much, much less difficult to tackle (and much, much easier to extend when new components are added).
I've only barely skimmed the article just now, but one of the biggest questions I've seen for Silverlight shutdown is how to do pretty much anything if the user decides to close by hitting the *browser's* close button. I've not tried this myself, but people seem to find some difficulty doing things like web service calls, etc. before their application gets terminated. Does your solution address this? If so, I think it would be worth calling specific attention to that in light of the interest I've seen already.
Thanks!
From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent Bugnion, GalaSoft Sent: Sunday, October 18, 2009 12:57 PM To: wpf-disciples@googlegroups.com Subject: [WPF Disciples] Clean shutdown in WPF and SL using a Messenger
Hey gang,
I just published a new article showing how to implement a clean shutdown sequence in a Silverlight and WPF application. The sample app uses the MVVM Light Toolkit Messenger, but of course this could also be implemented with other kind of messengers.
I have been confronted to this kind of issues in production applications in the past, with a lot of components having to shut down in a coordinated manner, and I think that having a decoupled messenger makes that issue much, much less difficult to tackle (and much, much easier to extend when new components are added).
AFAIK the only way to handle browser close or navigation to another site is to use IApplicationService (Silverlight3) unfortunately calls to webservices don't work. Solution we've considered (but not tried) is to use JS/JQuery to invoke it.
> I've only barely skimmed the article just now, but one of the > biggest questions I've seen for Silverlight shutdown is how to do > pretty much anything if the user decides to close by hitting the > *browser's* close button. I've not tried this myself, but people > seem to find some difficulty doing things like web service calls, > etc. before their application gets terminated. Does your solution > address this? If so, I think it would be worth calling specific > attention to that in light of the interest I've seen already.
> Thanks!
> From: wpf-disciples@googlegroups.com > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent > Bugnion, GalaSoft > Sent: Sunday, October 18, 2009 12:57 PM > To: wpf-disciples@googlegroups.com > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a > Messenger
> Hey gang,
> I just published a new article showing how to implement a clean > shutdown sequence in a Silverlight and WPF application. The > sample app uses the MVVM Light Toolkit Messenger, but of course > this could also be implemented with other kind of messengers.
> I have been confronted to this kind of issues in production > applications in the past, with a lot of components having to shut > down in a coordinated manner, and I think that having a decoupled > messenger makes that issue much, much less difficult to tackle > (and much, much easier to extend when new components are added).
No, the solution proposed here concentrates on taking actions when a user clicks on a button. For Silverlight to do something when the user closes the browser is an old problem (and it is not specific to Silverlight, we had this issue already in JavaScript back then). Unfortunately, even though Silverlight has a "Application.Exit" event, as far as I know there is no guarantee that operations executed there will be really performed, especially not asynchronous operations (but it will be called when the browser gets closed, so you can at least attempt to do something. Note that Application.Exit cannot be cancelled.
Also, in the contrary to WPF, there is no equivalent Window.Closing (that can be cancelled).
It's a good input, I will update the article to mention this. Thanks!!
Laurent
From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com] On Behalf Of David Anson Sent: Monday, October 19, 2009 9:39 AM To: wpf-disciples@googlegroups.com Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
Laurent,
I've only barely skimmed the article just now, but one of the biggest questions I've seen for Silverlight shutdown is how to do pretty much anything if the user decides to close by hitting the *browser's* close button. I've not tried this myself, but people seem to find some difficulty doing things like web service calls, etc. before their application gets terminated. Does your solution address this? If so, I think it would be worth calling specific attention to that in light of the interest I've seen already.
Thanks!
From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent Bugnion, GalaSoft Sent: Sunday, October 18, 2009 12:57 PM To: wpf-disciples@googlegroups.com Subject: [WPF Disciples] Clean shutdown in WPF and SL using a Messenger
Hey gang,
I just published a new article showing how to implement a clean shutdown sequence in a Silverlight and WPF application. The sample app uses the MVVM Light Toolkit Messenger, but of course this could also be implemented with other kind of messengers.
I have been confronted to this kind of issues in production applications in the past, with a lot of components having to shut down in a coordinated manner, and I think that having a decoupled messenger makes that issue much, much less difficult to tackle (and much, much easier to extend when new components are added).
Invoking JS when the browser is closing is very likely to fail. When I was still very active in JavaScript (yes, this is one dark aspect of my past, generally unknown ;) the specs of the browsers specified that nothing was guaranteed to be executed if the browser was closing down, especially not async operations such as web service calls.
If the intent is to log when a user is leaving a page or closing down, the only viable way is to have a heartbeat ping the web server at regular intervals, and log when the heart beat stops.
On Behalf Of Corrado Cavalli Sent: Monday, October 19, 2009 9:53 AM To: wpf-disciples@googlegroups.com Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
AFAIK the only way to handle browser close or navigation to another site is to use IApplicationService (Silverlight3) unfortunately calls to webservices don't work. Solution we've considered (but not tried) is to use JS/JQuery to invoke it.
-Corrado
On Mon Oct 19 02:38:56 CDT 2009, David Anson <david...@microsoft.com> wrote:
> Laurent,
> I've only barely skimmed the article just now, but one of the > biggest questions I've seen for Silverlight shutdown is how to do > pretty much anything if the user decides to close by hitting the > *browser's* close button. I've not tried this myself, but people > seem to find some difficulty doing things like web service calls, > etc. before their application gets terminated. Does your solution > address this? If so, I think it would be worth calling specific > attention to that in light of the interest I've seen already.
> Thanks!
> From: wpf-disciples@googlegroups.com > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent > Bugnion, GalaSoft > Sent: Sunday, October 18, 2009 12:57 PM > To: wpf-disciples@googlegroups.com > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a > Messenger
> Hey gang,
> I just published a new article showing how to implement a clean > shutdown sequence in a Silverlight and WPF application. The > sample app uses the MVVM Light Toolkit Messenger, but of course > this could also be implemented with other kind of messengers.
> I have been confronted to this kind of issues in production > applications in the past, with a lot of components having to shut > down in a coordinated manner, and I think that having a decoupled > messenger makes that issue much, much less difficult to tackle > (and much, much easier to extend when new components are added).
The conversation on this thread led me to do a little experimenting
this evening. So I thought I would share it with you guys. There are
two close interception points that I have examined. The first, and as
Laurent has said, unreliable interception point occurs after the
Silverlight App.Exit is raised; which I had a crack at using Ajax. And
the more reliable interception point uses the browsers onbeforeunload
event to assign a string to the event.returnValue, thereby giving time
to dispatch a web service call.
> Invoking JS when the browser is closing is very likely to fail. When I was
> still very active in JavaScript (yes, this is one dark aspect of my past,
> generally unknown ;) the specs of the browsers specified that nothing was
> guaranteed to be executed if the browser was closing down, especially not
> async operations such as web service calls.
> If the intent is to log when a user is leaving a page or closing down, the
> only viable way is to have a heartbeat ping the web server at regular
> intervals, and log when the heart beat stops.
> On Behalf Of Corrado Cavalli
> Sent: Monday, October 19, 2009 9:53 AM
> To: wpf-disciples@googlegroups.com
> Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> AFAIK the only way to handle browser close or navigation to
> another site is to use IApplicationService (Silverlight3)
> unfortunately calls to webservices don't work.
> Solution we've considered (but not tried) is to use JS/JQuery to
> invoke it.
> -Corrado
> On Mon Oct 19 02:38:56 CDT 2009, David Anson
> <david...@microsoft.com> wrote:
> > Laurent,
> > I've only barely skimmed the article just now, but one of the
> > biggest questions I've seen for Silverlight shutdown is how to do
> > pretty much anything if the user decides to close by hitting the
> > *browser's* close button. I've not tried this myself, but people
> > seem to find some difficulty doing things like web service calls,
> > etc. before their application gets terminated. Does your solution
> > address this? If so, I think it would be worth calling specific
> > attention to that in light of the interest I've seen already.
> > Thanks!
> > From: wpf-disciples@googlegroups.com
> > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent
> > Bugnion, GalaSoft
> > Sent: Sunday, October 18, 2009 12:57 PM
> > To: wpf-disciples@googlegroups.com
> > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a
> > Messenger
> > Hey gang,
> > I just published a new article showing how to implement a clean
> > shutdown sequence in a Silverlight and WPF application. The
> > sample app uses the MVVM Light Toolkit Messenger, but of course
> > this could also be implemented with other kind of messengers.
> > I have been confronted to this kind of issues in production
> > applications in the past, with a lot of components having to shut
> > down in a coordinated manner, and I think that having a decoupled
> > messenger makes that issue much, much less difficult to tackle
> > (and much, much easier to extend when new components are added).
On Mon, Oct 19, 2009 at 3:13 PM, Daniel Vaughan <dbvaug...@gmail.com> wrote:
> The conversation on this thread led me to do a little experimenting > this evening. So I thought I would share it with you guys. There are > two close interception points that I have examined. The first, and as > Laurent has said, unreliable interception point occurs after the > Silverlight App.Exit is raised; which I had a crack at using Ajax. And > the more reliable interception point uses the browsers onbeforeunload > event to assign a string to the event.returnValue, thereby giving time > to dispatch a web service call.
> On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch> > wrote: > > Hey Corrado,
> > Invoking JS when the browser is closing is very likely to fail. When I > was > > still very active in JavaScript (yes, this is one dark aspect of my past, > > generally unknown ;) the specs of the browsers specified that nothing was > > guaranteed to be executed if the browser was closing down, especially not > > async operations such as web service calls.
> > If the intent is to log when a user is leaving a page or closing down, > the > > only viable way is to have a heartbeat ping the web server at regular > > intervals, and log when the heart beat stops.
> > On Behalf Of Corrado Cavalli > > Sent: Monday, October 19, 2009 9:53 AM > > To: wpf-disciples@googlegroups.com > > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a > Messenger
> > AFAIK the only way to handle browser close or navigation to > > another site is to use IApplicationService (Silverlight3) > > unfortunately calls to webservices don't work. > > Solution we've considered (but not tried) is to use JS/JQuery to > > invoke it.
> > -Corrado
> > On Mon Oct 19 02:38:56 CDT 2009, David Anson > > <david...@microsoft.com> wrote:
> > > Laurent,
> > > I've only barely skimmed the article just now, but one of the > > > biggest questions I've seen for Silverlight shutdown is how to do > > > pretty much anything if the user decides to close by hitting the > > > *browser's* close button. I've not tried this myself, but people > > > seem to find some difficulty doing things like web service calls, > > > etc. before their application gets terminated. Does your solution > > > address this? If so, I think it would be worth calling specific > > > attention to that in light of the interest I've seen already.
> > > Thanks!
> > > From: wpf-disciples@googlegroups.com > > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent > > > Bugnion, GalaSoft > > > Sent: Sunday, October 18, 2009 12:57 PM > > > To: wpf-disciples@googlegroups.com > > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a > > > Messenger
> > > Hey gang,
> > > I just published a new article showing how to implement a clean > > > shutdown sequence in a Silverlight and WPF application. The > > > sample app uses the MVVM Light Toolkit Messenger, but of course > > > this could also be implemented with other kind of messengers.
> > > I have been confronted to this kind of issues in production > > > applications in the past, with a lot of components having to shut > > > down in a coordinated manner, and I think that having a decoupled > > > messenger makes that issue much, much less difficult to tackle > > > (and much, much easier to extend when new components are added).
> On Mon, Oct 19, 2009 at 3:13 PM, Daniel Vaughan <dbvaug...@gmail.com> wrote:
> > The conversation on this thread led me to do a little experimenting
> > this evening. So I thought I would share it with you guys. There are
> > two close interception points that I have examined. The first, and as
> > Laurent has said, unreliable interception point occurs after the
> > Silverlight App.Exit is raised; which I had a crack at using Ajax. And
> > the more reliable interception point uses the browsers onbeforeunload
> > event to assign a string to the event.returnValue, thereby giving time
> > to dispatch a web service call.
> > On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch>
> > wrote:
> > > Hey Corrado,
> > > Invoking JS when the browser is closing is very likely to fail. When I
> > was
> > > still very active in JavaScript (yes, this is one dark aspect of my past,
> > > generally unknown ;) the specs of the browsers specified that nothing was
> > > guaranteed to be executed if the browser was closing down, especially not
> > > async operations such as web service calls.
> > > If the intent is to log when a user is leaving a page or closing down,
> > the
> > > only viable way is to have a heartbeat ping the web server at regular
> > > intervals, and log when the heart beat stops.
> > > On Behalf Of Corrado Cavalli
> > > Sent: Monday, October 19, 2009 9:53 AM
> > > To: wpf-disciples@googlegroups.com
> > > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a
> > Messenger
> > > AFAIK the only way to handle browser close or navigation to
> > > another site is to use IApplicationService (Silverlight3)
> > > unfortunately calls to webservices don't work.
> > > Solution we've considered (but not tried) is to use JS/JQuery to
> > > invoke it.
> > > -Corrado
> > > On Mon Oct 19 02:38:56 CDT 2009, David Anson
> > > <david...@microsoft.com> wrote:
> > > > Laurent,
> > > > I've only barely skimmed the article just now, but one of the
> > > > biggest questions I've seen for Silverlight shutdown is how to do
> > > > pretty much anything if the user decides to close by hitting the
> > > > *browser's* close button. I've not tried this myself, but people
> > > > seem to find some difficulty doing things like web service calls,
> > > > etc. before their application gets terminated. Does your solution
> > > > address this? If so, I think it would be worth calling specific
> > > > attention to that in light of the interest I've seen already.
> > > > Thanks!
> > > > From: wpf-disciples@googlegroups.com
> > > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent
> > > > Bugnion, GalaSoft
> > > > Sent: Sunday, October 18, 2009 12:57 PM
> > > > To: wpf-disciples@googlegroups.com
> > > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a
> > > > Messenger
> > > > Hey gang,
> > > > I just published a new article showing how to implement a clean
> > > > shutdown sequence in a Silverlight and WPF application. The
> > > > sample app uses the MVVM Light Toolkit Messenger, but of course
> > > > this could also be implemented with other kind of messengers.
> > > > I have been confronted to this kind of issues in production
> > > > applications in the past, with a lot of components having to shut
> > > > down in a coordinated manner, and I think that having a decoupled
> > > > messenger makes that issue much, much less difficult to tackle
> > > > (and much, much easier to extend when new components are added).
-----Original Message----- From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com] On Behalf Of Daniel Vaughan Sent: Monday, October 19, 2009 3:13 PM To: WPF Disciples Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
The conversation on this thread led me to do a little experimenting this evening. So I thought I would share it with you guys. There are two close interception points that I have examined. The first, and as Laurent has said, unreliable interception point occurs after the Silverlight App.Exit is raised; which I had a crack at using Ajax. And the more reliable interception point uses the browsers onbeforeunload event to assign a string to the event.returnValue, thereby giving time to dispatch a web service call.
On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch> wrote: > Hey Corrado,
> Invoking JS when the browser is closing is very likely to fail. When I was > still very active in JavaScript (yes, this is one dark aspect of my past, > generally unknown ;) the specs of the browsers specified that nothing was > guaranteed to be executed if the browser was closing down, especially not > async operations such as web service calls.
> If the intent is to log when a user is leaving a page or closing down, the > only viable way is to have a heartbeat ping the web server at regular > intervals, and log when the heart beat stops.
> On Behalf Of Corrado Cavalli > Sent: Monday, October 19, 2009 9:53 AM > To: wpf-disciples@googlegroups.com > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> AFAIK the only way to handle browser close or navigation to > another site is to use IApplicationService (Silverlight3) > unfortunately calls to webservices don't work. > Solution we've considered (but not tried) is to use JS/JQuery to > invoke it.
> -Corrado
> On Mon Oct 19 02:38:56 CDT 2009, David Anson > <david...@microsoft.com> wrote:
> > Laurent,
> > I've only barely skimmed the article just now, but one of the > > biggest questions I've seen for Silverlight shutdown is how to do > > pretty much anything if the user decides to close by hitting the > > *browser's* close button. I've not tried this myself, but people > > seem to find some difficulty doing things like web service calls, > > etc. before their application gets terminated. Does your solution > > address this? If so, I think it would be worth calling specific > > attention to that in light of the interest I've seen already.
> > Thanks!
> > From: wpf-disciples@googlegroups.com > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent > > Bugnion, GalaSoft > > Sent: Sunday, October 18, 2009 12:57 PM > > To: wpf-disciples@googlegroups.com > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a > > Messenger
> > Hey gang,
> > I just published a new article showing how to implement a clean > > shutdown sequence in a Silverlight and WPF application. The > > sample app uses the MVVM Light Toolkit Messenger, but of course > > this could also be implemented with other kind of messengers.
> > I have been confronted to this kind of issues in production > > applications in the past, with a lot of components having to shut > > down in a coordinated manner, and I think that having a decoupled > > messenger makes that issue much, much less difficult to tackle > > (and much, much easier to extend when new components are added).
> -----Original Message-----
> From: wpf-disciples@googlegroups.com [mailto:wpf-disciples@googlegroups.com] On Behalf Of Daniel Vaughan
> Sent: Monday, October 19, 2009 3:13 PM
> To: WPF Disciples
> Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> The conversation on this thread led me to do a little experimenting
> this evening. So I thought I would share it with you guys. There are
> two close interception points that I have examined. The first, and as
> Laurent has said, unreliable interception point occurs after the
> Silverlight App.Exit is raised; which I had a crack at using Ajax. And
> the more reliable interception point uses the browsers onbeforeunload
> event to assign a string to the event.returnValue, thereby giving time
> to dispatch a web service call.
> On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch>
> wrote:
> > Hey Corrado,
> > Invoking JS when the browser is closing is very likely to fail. When I was
> > still very active in JavaScript (yes, this is one dark aspect of my past,
> > generally unknown ;) the specs of the browsers specified that nothing was
> > guaranteed to be executed if the browser was closing down, especially not
> > async operations such as web service calls.
> > If the intent is to log when a user is leaving a page or closing down, the
> > only viable way is to have a heartbeat ping the web server at regular
> > intervals, and log when the heart beat stops.
> > On Behalf Of Corrado Cavalli
> > Sent: Monday, October 19, 2009 9:53 AM
> > To: wpf-disciples@googlegroups.com
> > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> > AFAIK the only way to handle browser close or navigation to
> > another site is to use IApplicationService (Silverlight3)
> > unfortunately calls to webservices don't work.
> > Solution we've considered (but not tried) is to use JS/JQuery to
> > invoke it.
> > -Corrado
> > On Mon Oct 19 02:38:56 CDT 2009, David Anson
> > <david...@microsoft.com> wrote:
> > > Laurent,
> > > I've only barely skimmed the article just now, but one of the
> > > biggest questions I've seen for Silverlight shutdown is how to do
> > > pretty much anything if the user decides to close by hitting the
> > > *browser's* close button. I've not tried this myself, but people
> > > seem to find some difficulty doing things like web service calls,
> > > etc. before their application gets terminated. Does your solution
> > > address this? If so, I think it would be worth calling specific
> > > attention to that in light of the interest I've seen already.
> > > Thanks!
> > > From: wpf-disciples@googlegroups.com
> > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent
> > > Bugnion, GalaSoft
> > > Sent: Sunday, October 18, 2009 12:57 PM
> > > To: wpf-disciples@googlegroups.com
> > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a
> > > Messenger
> > > Hey gang,
> > > I just published a new article showing how to implement a clean
> > > shutdown sequence in a Silverlight and WPF application. The
> > > sample app uses the MVVM Light Toolkit Messenger, but of course
> > > this could also be implemented with other kind of messengers.
> > > I have been confronted to this kind of issues in production
> > > applications in the past, with a lot of components having to shut
> > > down in a coordinated manner, and I think that having a decoupled
> > > messenger makes that issue much, much less difficult to tackle
> > > (and much, much easier to extend when new components are added).
On Behalf Of Daniel Vaughan Sent: marted́ 20 ottobre 2009 00:13 To: WPF Disciples Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
The conversation on this thread led me to do a little experimenting this evening. So I thought I would share it with you guys. There are two close interception points that I have examined. The first, and as Laurent has said, unreliable interception point occurs after the Silverlight App.Exit is raised; which I had a crack at using Ajax. And the more reliable interception point uses the browsers onbeforeunload event to assign a string to the event.returnValue, thereby giving time to dispatch a web service call.
On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch> wrote: > Hey Corrado,
> Invoking JS when the browser is closing is very likely to fail. When I > was still very active in JavaScript (yes, this is one dark aspect of > my past, generally unknown ;) the specs of the browsers specified that > nothing was guaranteed to be executed if the browser was closing down, > especially not async operations such as web service calls.
> If the intent is to log when a user is leaving a page or closing down, > the only viable way is to have a heartbeat ping the web server at > regular intervals, and log when the heart beat stops.
> On Behalf Of Corrado Cavalli > Sent: Monday, October 19, 2009 9:53 AM > To: wpf-disciples@googlegroups.com > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a > Messenger
> AFAIK the only way to handle browser close or navigation to another > site is to use IApplicationService (Silverlight3) unfortunately calls > to webservices don't work. > Solution we've considered (but not tried) is to use JS/JQuery to > invoke it.
> -Corrado
> On Mon Oct 19 02:38:56 CDT 2009, David Anson <david...@microsoft.com> > wrote:
> > Laurent,
> > I've only barely skimmed the article just now, but one of the > > biggest questions I've seen for Silverlight shutdown is how to do > > pretty much anything if the user decides to close by hitting the > > *browser's* close button. I've not tried this myself, but people > > seem to find some difficulty doing things like web service calls, > > etc. before their application gets terminated. Does your solution > > address this? If so, I think it would be worth calling specific > > attention to that in light of the interest I've seen already.
> > Thanks!
> > From: wpf-disciples@googlegroups.com > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent > > Bugnion, GalaSoft > > Sent: Sunday, October 18, 2009 12:57 PM > > To: wpf-disciples@googlegroups.com > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a > > Messenger
> > Hey gang,
> > I just published a new article showing how to implement a clean > > shutdown sequence in a Silverlight and WPF application. The sample > > app uses the MVVM Light Toolkit Messenger, but of course this could > > also be implemented with other kind of messengers.
> > I have been confronted to this kind of issues in production > > applications in the past, with a lot of components having to shut > > down in a coordinated manner, and I think that having a decoupled > > messenger makes that issue much, much less difficult to tackle (and > > much, much easier to extend when new components are added).
Disclaimer: i didn't write serious JavaScript code for quite some time so things might not be as i remember them anymore ;)
I didn't try, but i think it will be exactly the same. One of the difficulties of this exercise is that it is impossible to distinguish between the page being navigated away from, and the browser being shut down, because the events involved are exactly the same.
The article is great, and it would be very interesting to test on multiple browsers to see how they react. One caveat of using onbeforeunload in JavaScript is that IIRC it is not a standard event (or at least it was not when i used to write JavaScript code) so it might fail in some browsers (ah the joy of cross browser coding, i miss that... NOT)
Cheers, Laurent -- Sent from mobile
-original message- Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger From: "Corrado Cavalli" <corradocava...@gmail.com> Date: 20.10.2009 06:32
Superb article Daniel! Does that work even when user navigates away from the application? (wondering about 2nd approach...)
On Behalf Of Daniel Vaughan Sent: marted́ 20 ottobre 2009 00:13 To: WPF Disciples Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
The conversation on this thread led me to do a little experimenting this evening. So I thought I would share it with you guys. There are two close interception points that I have examined. The first, and as Laurent has said, unreliable interception point occurs after the Silverlight App.Exit is raised; which I had a crack at using Ajax. And the more reliable interception point uses the browsers onbeforeunload event to assign a string to the event.returnValue, thereby giving time to dispatch a web service call.
On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch> wrote: > Hey Corrado,
> Invoking JS when the browser is closing is very likely to fail. When I > was still very active in JavaScript (yes, this is one dark aspect of > my past, generally unknown ;) the specs of the browsers specified that > nothing was guaranteed to be executed if the browser was closing down, > especially not async operations such as web service calls.
> If the intent is to log when a user is leaving a page or closing down, > the only viable way is to have a heartbeat ping the web server at > regular intervals, and log when the heart beat stops.
> On Behalf Of Corrado Cavalli > Sent: Monday, October 19, 2009 9:53 AM > To: wpf-disciples@googlegroups.com > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a > Messenger
> AFAIK the only way to handle browser close or navigation to another > site is to use IApplicationService (Silverlight3) unfortunately calls > to webservices don't work. > Solution we've considered (but not tried) is to use JS/JQuery to > invoke it.
> -Corrado
> On Mon Oct 19 02:38:56 CDT 2009, David Anson <david...@microsoft.com> > wrote:
> > Laurent,
> > I've only barely skimmed the article just now, but one of the > > biggest questions I've seen for Silverlight shutdown is how to do > > pretty much anything if the user decides to close by hitting the > > *browser's* close button. I've not tried this myself, but people > > seem to find some difficulty doing things like web service calls, > > etc. before their application gets terminated. Does your solution > > address this? If so, I think it would be worth calling specific > > attention to that in light of the interest I've seen already.
> > Thanks!
> > From: wpf-disciples@googlegroups.com > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent > > Bugnion, GalaSoft > > Sent: Sunday, October 18, 2009 12:57 PM > > To: wpf-disciples@googlegroups.com > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a > > Messenger
> > Hey gang,
> > I just published a new article showing how to implement a clean > > shutdown sequence in a Silverlight and WPF application. The sample > > app uses the MVVM Light Toolkit Messenger, but of course this could > > also be implemented with other kind of messengers.
> > I have been confronted to this kind of issues in production > > applications in the past, with a lot of components having to shut > > down in a coordinated manner, and I think that having a decoupled > > messenger makes that issue much, much less difficult to tackle (and > > much, much easier to extend when new components are added).
I've tested it with IE8 and FF3.5.3, and the second method worked
locally when the user navigates away using a bookmark, url in
navigation bar, and a hyperlink on the page.
Cheers,
Daniel
On Oct 20, 6:31 am, "Corrado Cavalli" <corradocava...@gmail.com>
wrote:
> On Behalf Of Daniel Vaughan
> Sent: marted́ 20 ottobre 2009 00:13
> To: WPF Disciples
> Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> The conversation on this thread led me to do a little experimenting this
> evening. So I thought I would share it with you guys. There are two close
> interception points that I have examined. The first, and as Laurent has
> said, unreliable interception point occurs after the Silverlight App.Exit is
> raised; which I had a crack at using Ajax. And the more reliable
> interception point uses the browsers onbeforeunload event to assign a string
> to the event.returnValue, thereby giving time to dispatch a web service
> call.
> On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch>
> wrote:
> > Hey Corrado,
> > Invoking JS when the browser is closing is very likely to fail. When I
> > was still very active in JavaScript (yes, this is one dark aspect of
> > my past, generally unknown ;) the specs of the browsers specified that
> > nothing was guaranteed to be executed if the browser was closing down,
> > especially not async operations such as web service calls.
> > If the intent is to log when a user is leaving a page or closing down,
> > the only viable way is to have a heartbeat ping the web server at
> > regular intervals, and log when the heart beat stops.
> > On Behalf Of Corrado Cavalli
> > Sent: Monday, October 19, 2009 9:53 AM
> > To: wpf-disciples@googlegroups.com
> > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a
> > Messenger
> > AFAIK the only way to handle browser close or navigation to another
> > site is to use IApplicationService (Silverlight3) unfortunately calls
> > to webservices don't work.
> > Solution we've considered (but not tried) is to use JS/JQuery to
> > invoke it.
> > -Corrado
> > On Mon Oct 19 02:38:56 CDT 2009, David Anson <david...@microsoft.com>
> > wrote:
> > > Laurent,
> > > I've only barely skimmed the article just now, but one of the
> > > biggest questions I've seen for Silverlight shutdown is how to do
> > > pretty much anything if the user decides to close by hitting the
> > > *browser's* close button. I've not tried this myself, but people
> > > seem to find some difficulty doing things like web service calls,
> > > etc. before their application gets terminated. Does your solution
> > > address this? If so, I think it would be worth calling specific
> > > attention to that in light of the interest I've seen already.
> > > Thanks!
> > > From: wpf-disciples@googlegroups.com
> > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent
> > > Bugnion, GalaSoft
> > > Sent: Sunday, October 18, 2009 12:57 PM
> > > To: wpf-disciples@googlegroups.com
> > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a
> > > Messenger
> > > Hey gang,
> > > I just published a new article showing how to implement a clean
> > > shutdown sequence in a Silverlight and WPF application. The sample
> > > app uses the MVVM Light Toolkit Messenger, but of course this could
> > > also be implemented with other kind of messengers.
> > > I have been confronted to this kind of issues in production
> > > applications in the past, with a lot of components having to shut
> > > down in a coordinated manner, and I think that having a decoupled
> > > messenger makes that issue much, much less difficult to tackle (and
> > > much, much easier to extend when new components are added).
> Disclaimer: i didn't write serious JavaScript code for quite some time so things might not be as i remember them anymore ;)
> I didn't try, but i think it will be exactly the same. One of the difficulties of this exercise is that it is impossible to distinguish between the page being navigated away from, and the browser being shut down, because the events involved are exactly the same.
> The article is great, and it would be very interesting to test on multiple browsers to see how they react. One caveat of using onbeforeunload in JavaScript is that IIRC it is not a standard event (or at least it was not when i used to write JavaScript code) so it might fail in some browsers (ah the joy of cross browser coding, i miss that... NOT)
> Cheers,
> Laurent
> --
> Sent from mobile
> -original message-
> Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> From: "Corrado Cavalli" <corradocava...@gmail.com>
> Date: 20.10.2009 06:32
> Superb article Daniel!
> Does that work even when user navigates away from the application?
> (wondering about 2nd approach...)
> On Behalf Of Daniel Vaughan
> Sent: marted́ 20 ottobre 2009 00:13
> To: WPF Disciples
> Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a Messenger
> The conversation on this thread led me to do a little experimenting this
> evening. So I thought I would share it with you guys. There are two close
> interception points that I have examined. The first, and as Laurent has
> said, unreliable interception point occurs after the Silverlight App.Exit is
> raised; which I had a crack at using Ajax. And the more reliable
> interception point uses the browsers onbeforeunload event to assign a string
> to the event.returnValue, thereby giving time to dispatch a web service
> call.
> On Oct 19, 10:25 am, "Laurent Bugnion, GalaSoft" <laur...@galasoft.ch>
> wrote:
> > Hey Corrado,
> > Invoking JS when the browser is closing is very likely to fail. When I
> > was still very active in JavaScript (yes, this is one dark aspect of
> > my past, generally unknown ;) the specs of the browsers specified that
> > nothing was guaranteed to be executed if the browser was closing down,
> > especially not async operations such as web service calls.
> > If the intent is to log when a user is leaving a page or closing down,
> > the only viable way is to have a heartbeat ping the web server at
> > regular intervals, and log when the heart beat stops.
> > On Behalf Of Corrado Cavalli
> > Sent: Monday, October 19, 2009 9:53 AM
> > To: wpf-disciples@googlegroups.com
> > Subject: [WPF Disciples] Re: Clean shutdown in WPF and SL using a
> > Messenger
> > AFAIK the only way to handle browser close or navigation to another
> > site is to use IApplicationService (Silverlight3) unfortunately calls
> > to webservices don't work.
> > Solution we've considered (but not tried) is to use JS/JQuery to
> > invoke it.
> > -Corrado
> > On Mon Oct 19 02:38:56 CDT 2009, David Anson <david...@microsoft.com>
> > wrote:
> > > Laurent,
> > > I've only barely skimmed the article just now, but one of the
> > > biggest questions I've seen for Silverlight shutdown is how to do
> > > pretty much anything if the user decides to close by hitting the
> > > *browser's* close button. I've not tried this myself, but people
> > > seem to find some difficulty doing things like web service calls,
> > > etc. before their application gets terminated. Does your solution
> > > address this? If so, I think it would be worth calling specific
> > > attention to that in light of the interest I've seen already.
> > > Thanks!
> > > From: wpf-disciples@googlegroups.com
> > > [mailto:wpf-disciples@googlegroups.com] On Behalf Of Laurent
> > > Bugnion, GalaSoft
> > > Sent: Sunday, October 18, 2009 12:57 PM
> > > To: wpf-disciples@googlegroups.com
> > > Subject: [WPF Disciples] Clean shutdown in WPF and SL using a
> > > Messenger
> > > Hey gang,
> > > I just published a new article showing how to implement a clean
> > > shutdown sequence in a Silverlight and WPF application. The sample
> > > app uses the MVVM Light Toolkit Messenger, but of course this could
> > > also be implemented with other kind of messengers.
> > > I have been confronted to this kind of issues in production
> > > applications in the past, with a lot of components having to shut
> > > down in a coordinated manner, and I think that having a decoupled
> > > messenger makes that issue much, much less difficult to tackle (and
> > > much, much easier to extend when new components are added).