Win an Ipad
  Developer   Documents   Application life cyc ...

Application life cycle

This document provides basic information about Moscrif application's life cycle.

Application start

Application start is initiated by an application file with extension .app. It contains information about the startup file of the application. Typically, the name of the file is main.ms but that doesn't always have to be the case.


If Moscrif project is not compiled source code is kept in files with extension *.ms. If project is compiled Moscrif executes files with extension *.msc.

  1.     
  2. Loading application.app    
  3. Searching for startup file (typically main.ms or its compiled version main.msc)    
  4. Loads and executes startup file

Application life cycle

 

 

Application with Moscrif native User Interface consists of following life-cycle with corresponding events:

  1.     
  2. Create application global object (thanks to Window native class)    
  3. Initialise application by Window.init. This function invokes onStart event handler. Initialisation is done in the background as the very first event, while the splash screen is showing.    
  4. Run application by Window.run. This function creates main application loop. Within this loop application events are fired like user input events touching or pressing  on the device screen, scheduled callbacks and timers, etc.

// Construncting global application object
var app = new Moscrif.Window(); // Handling (system) events
app.onStart = function(sender)
{
    // initialisation goes here
} app.onProcess = function(sender)
{
    // logic goes here
} app.onDraw = function(sender, canvas)
{
    // drawing goes here
} // other user events like onProcess, onDraw, onPointerPressed
app.onXXX = function(sender, …)
{
    // event handler goes here
} app.init(); // invoke initialisation process (onStart will be called) app.run(); // invoke event loop

Function Window.run is an exit point of running application . In the case, handler onStart is called after exit point, initiation will never take place. Moscrif initialisation and run must be always located at the end of application definition.

Following example shows wrong usage Window.init and Window.Run methods:

var app = new Moscrif.Window();
app.init();
app.run(); app.onStart = function(sender) {
    ... }


Background & Foreground

 

Application can be broght to the backround or foregraund during at any time when event onForeground or onBackground is fired. 

An application moves to foreground when:

  • Application starts
  • Application is selected from Task Manager
  • Application is restored form hibernation
  • Application becomes active after system calls (incoming call etc …) finish


An application moves to background when:

  • Application moves to hibernation state
  • Other application is activated
  • In the case of  system calls (incoming call or displaying other system dialog or window)

 

 Moscrif in 5 mins   Application life cycle   Basics 
Write a Comment (0)
Subject
Please complete this mandatory field.
HTML Tags Not Allowed!
Comment
Please complete this mandatory field.