function Process(fnExecutor, oProcessInfo) {
		var bRunning = true;
		var bCancelled = false;
		var aCancelListeners = [];
		var oProcessInterface = {
			cancel: function() {
				if (this.isCancelled() || !this.isRunning()) {
					return;
				}

				bCancelled = true;

				for (var i = 0; i < aCancelListeners.length; i++) {
					aCancelListeners[i]();
				}

				log("Process cancelled: " + oProcessInfo.id);
			},
			isCancelled: function() {
				return bCancelled;
			},
			addCancelListener: function(fnCallback) {
				aCancelListeners.push(fnCallback);
			},
			isRunning: function() {
				return bRunning;
			},
			getInfo: function() {
				return oProcessInfo;
			},
			onPromiseCreated: function(oPromise) {}
		};
		var pCancellablePromise;

		log("Process started: " + oProcessInfo.id);

		if (typeof fnExecutor === "function") {
			pCancellablePromise = new Promise(function() {
				fnExecutor.apply(this, Array.prototype.slice.call(arguments).concat(oProcessInterface));
			});
		} else {
			pCancellablePromise = Promise.resolve();
		}

		Object.assign(pCancellablePromise, oProcessInterface);

		pCancellablePromise.then(function() {
			if (oProcessInterface.isCancelled()) {
				log("Process finished due to cancellation: " + oProcessInfo.id);
			} else {
				log("Process finished: " + oProcessInfo.id);
			}
			bRunning = false;
		});

		oProcessInterface.onPromiseCreated(pCancellablePromise);

		return pCancellablePromise;
	}
/**
	 * Constructor for a Process.
	 *
	 * @param {Executor} fnExecutor The function to be executed.
	 * @param {ProcessInfo} oProcessInfo The process information.
	 * @returns {Promise} The process promise.
	 * @constructor
	 */
Constructor for a Process.
@param {Executor} fnExecutor The function to be executed.
Constructor for a Process . @param { Executor } fnExecutor The function to be executed .
function Process(fnExecutor, oProcessInfo) {
		var bRunning = true;
		var bCancelled = false;
		var aCancelListeners = [];
		var oProcessInterface = {
			cancel: function() {
				if (this.isCancelled() || !this.isRunning()) {
					return;
				}
				bCancelled = true;
				for (var i = 0; i < aCancelListeners.length; i++) {
					aCancelListeners[i]();
				}
				log("Process cancelled: " + oProcessInfo.id);
			},
			isCancelled: function() {
				return bCancelled;
			},
			addCancelListener: function(fnCallback) {
				aCancelListeners.push(fnCallback);
			},
			isRunning: function() {
				return bRunning;
			},
			getInfo: function() {
				return oProcessInfo;
			},
			onPromiseCreated: function(oPromise) {}
		};
		var pCancellablePromise;
		log("Process started: " + oProcessInfo.id);
		if (typeof fnExecutor === "function") {
			pCancellablePromise = new Promise(function() {
				fnExecutor.apply(this, Array.prototype.slice.call(arguments).concat(oProcessInterface));
			});
		} else {
			pCancellablePromise = Promise.resolve();
		}
		Object.assign(pCancellablePromise, oProcessInterface);
		pCancellablePromise.then(function() {
			if (oProcessInterface.isCancelled()) {
				log("Process finished due to cancellation: " + oProcessInfo.id);
			} else {
				log("Process finished: " + oProcessInfo.id);
			}
			bRunning = false;
		});
		oProcessInterface.onPromiseCreated(pCancellablePromise);
		return pCancellablePromise;
	}
function Process ( fnExecutor , oProcessInfo ) { var bRunning = true ; var bCancelled = false ; var aCancelListeners = [ ] ; var oProcessInterface = { cancel : function ( ) { if ( this . isCancelled ( ) || ! this . isRunning ( ) ) { return ; } bCancelled = true ; for ( var i = 0 ; i < aCancelListeners . length ; i ++ ) { aCancelListeners [ i ] ( ) ; } log ( "Process cancelled: " + oProcessInfo . id ) ; } , isCancelled : function ( ) { return bCancelled ; } , addCancelListener : function ( fnCallback ) { aCancelListeners . push ( fnCallback ) ; } , isRunning : function ( ) { return bRunning ; } , getInfo : function ( ) { return oProcessInfo ; } , onPromiseCreated : function ( oPromise ) { } } ; var pCancellablePromise ; log ( "Process started: " + oProcessInfo . id ) ; if ( typeof fnExecutor === "function" ) { pCancellablePromise = new Promise ( function ( ) { fnExecutor . apply ( this , Array . prototype . slice . call ( arguments ) . concat ( oProcessInterface ) ) ; } ) ; } else { pCancellablePromise = Promise . resolve ( ) ; } Object . assign ( pCancellablePromise , oProcessInterface ) ; pCancellablePromise . then ( function ( ) { if ( oProcessInterface . isCancelled ( ) ) { log ( "Process finished due to cancellation: " + oProcessInfo . id ) ; } else { log ( "Process finished: " + oProcessInfo . id ) ; } bRunning = false ; } ) ; oProcessInterface . onPromiseCreated ( pCancellablePromise ) ; return pCancellablePromise ; }
Constructor for a Process.
Constructor for a Process .