Zhong Liu
Posts: 0
Joined: Tue Jun 17, 2014 3:27 am

How to init a background thread when app is loaded

Hello,
I need load a background thread, to scan files to be uploaded to backend. could someone give me some advises on this, thank you.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to init a background thread when app is loaded

Hi Zhong.

Please follow these steps:

  1. Open your start page(see in app settings) in design mode.

  2. Open events bottom panel.

  3. Add "Page load" JS event for this page and populate it with following code: http://prntscr.com/3u9xb5/direct

    pre

    var onNewThread = function(){
    //Here you should place the logic code you need in the new thread.
    console.log("new thread in work");
    };

    window.setTimeout(onNewThread, 100);

    /pre

    Regards.

Zhong Liu
Posts: 0
Joined: Tue Jun 17, 2014 3:27 am

How to init a background thread when app is loaded

Thank you, Yurii.

Zhong Liu
Posts: 0
Joined: Tue Jun 17, 2014 3:27 am

How to init a background thread when app is loaded

and, how to avoid re-create the thread, can I query whether the thread is exist before create the thread?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to init a background thread when app is loaded

Zhong,

You can modify code with following:

pre

var onNewThread = function(){

Code: Select all

 //Start thread 
 self.startThreadWorking = true; 

 //Here you should place the logic code you need in the new thread. 
 console.log("new thread in work"); 

 //End thread. 
 self.startThreadWorking = false; 

};
if(!self.startThreadWorking)
window.setTimeout(onNewThread, 100);

/pre

Regards.

Return to “Issues”