Menu

Software Development Company

September 30, 2016 - Software
Software Development Company

Handling suspending, termination, and shutting

There are many ways in which an application can leave the important condition. We’ve already talked about a few these, but there’s two additional situations. One happens when an application is wiped out and ranges from running à not running either because something went wrong using the application, just like a crash, or since the user has forced the application to shut lower within the task manager. (Wiped out isn’t the official term, but is extremely convenient for recalling this lifecycle path.) Another happens when an application is closed with a user utilizing a close gesture during tablet mode or hitting the X when ruling the desktop.  Within this situation, the software development company is suspended after which instantly ended.
We’re here likely to discuss situations by which an application is suspended after which ended. Used, what this means is we love them when the application is ended through the operating-system (first scenario) and when the consumer deliberately shuts the application (last scenario).

Software Development Company

Software Development Company

When an application is suspended, it invokes the Suspending event. Visual Studio’s UWP project templates instantly produce a handler with this event known as OnSuspending within the Application.xaml class. It’s here that you ought to place code in order to save software development company condition information just just in case the application terminates.

When the application doesn’t terminate following suspension, then no harm is completed because the application condition isn’t lost.

Similarly, when the application shuts lower carrying out a running condition without suspension, you don’t need to complete anything. Actually, there’s nothing you could do this, since no lifecycle occasions are invoked.

Here’s some example code showing how you can save condition information. Since saving to some FileStream is definitely an asynchronous process, you’ll note adding the async keyword towards the default implementation from the OnSuspending method. Since the _store object used is really a generic Dictionary, any kind of serializable data can be included to it to save. For brevity, you’re only adding a timestamp. (In addition, there’s some code for something known as deferral, which we’ll address later.)

Facebooktwittergoogle_plusredditpinterestlinkedinmail