Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #74 - Monitoring for App.Current Events - Startup, UnhandledException & Exit.

Ever noticed there was an event off the Page class called Loaded() that tells you when the page is loaded but none for for Exit() or Quit()?

Example for Page.Loaded():

public Page()
{
    InitializeComponent();
 
    this.Loaded += new RoutedEventHandler(Page_Loaded);
}
 
void Page_Loaded(object sender, RoutedEventArgs e)
{
    
}

One way to monitor for the Exit() event in your Page class is to subscribe to the App.Current.Exit() event. Example:

public Page()
{
    InitializeComponent();
            
    App.Current.Exit += new EventHandler(Current_Exit);
}
 
void Current_Exit(object sender, EventArgs e)
{
 
}

In addition to the Exit() event there is also:

  1. App.Current.Startup()
  2. App.Current.UnhandledException()

Thank you,
--Mike Snow

 Subscribe in a reader

Comments

Microsoft Weblogs said:

Ever noticed there was an event off the Page class called Loaded() that tells you when the page is loaded

# November 25, 2008 6:08 PM

GearWorld said:

I did try App.Current.Exit and either it never gets in the event or I can a HRESULT error

Can you explain exactly WHEN and what this even is for ?

The real moment when it'll gets in.  You see, I'm looking for a way to know when the plugins goes out of range like if the user quit the application

# November 25, 2008 6:20 PM

Tip of the Day - Pages, Threading und Monitoring at Programming with Silverlight, WPF & .NET said:

Pingback from  Tip of the Day - Pages, Threading und Monitoring at Programming with Silverlight, WPF & .NET

# November 26, 2008 3:34 AM

2008 November 26 - Links for today « My (almost) Daily Links said:

Pingback from  2008 November 26 - Links for today « My (almost) Daily Links

# November 26, 2008 4:03 AM

Dew Drop - November 26, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - November 26, 2008 | Alvin Ashcraft's Morning Dew

# November 26, 2008 11:26 AM

mike.snow said:

GearWorld - I get this message when I close the browser. Thanks.

# November 26, 2008 2:22 PM

Community Blogs said:

Happy Thanksgiving everyone! In this issue: Martin Mihaylov, Tim Heuer, Katrien De Graeve, Expression

# November 27, 2008 2:33 PM

mamadero2 said:

Mike, but it's not the same, one could 'close' or remove the page. So we don' thave a way to know when one view is closed

# November 29, 2008 4:06 AM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight tips of the

# January 2, 2009 5:56 PM

o UAU nosso de cada dia said:

essa lista eu copiei desse blog bárbaro (acompanhe por RSS você também): uma lista de dicas super úteis

# January 3, 2009 6:25 AM

Visual Web Developer Team Blog said:

This link provides a complete Tips of the Day Summary Outline - silverlight.net/.../silverlight-tips-of-the-day-summary-outline.aspx

# January 8, 2009 6:37 PM