User Tools

Site Tools

Background Progress


Below is an example demonstrating how you can cause the background_progress indicator to be displayed in the Status Bar and report progress via script.

API Areas of Interest


// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
	// Declare the total number of cycles
	var nCycles = 100000;
	// Declare how frequently you want to update the progress
	var nFrequency = 100;
	// Define whether or not the user can cancel
	var bCancellable = true;
	// Start the progress
	startBackgroundProgress( "This is a simple background progress test.", nCycles/nFrequency, bCancellable );
	// Iterate over the total number of cycles
	for( var i = 0; i < nCycles; i += 1 ){
		// If the iteration is divisible by the frequency, with no remainder
		if( i % nFrequency == 0 ){
			// Step the progress by 1
			stepBackgroundProgress( 1 );
			// Force any pending events to be processed
			// i.e. updating the status bar progress indicator
		// If the user is allowed to cancel
		if( bCancellable ){
			// Process events so that we can check user interaction
			// If the user cancelled
			if( backgroundProgressIsCancelled() ){
				// We're done...
	// Finish the progress
// Finalize the function and invoke