1 line
2.5 KiB
JavaScript
1 line
2.5 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI"),Sys.Extended.UI.DeferredOperation=function(t,e,l){this._delay=t,this._context=e,this._callback=l,this._completeCallback=null,this._errorCallback=null,this._timer=null,this._callArgs=null,this._isComplete=!1,this._completedSynchronously=!1,this._asyncResult=null,this._exception=null,this._throwExceptions=!0,this._oncomplete$delegate=Function.createDelegate(this,this._oncomplete),this.post=Function.createDelegate(this,this.post)},Sys.Extended.UI.DeferredOperation.prototype={get_isPending:function(){return null!=this._timer},get_isComplete:function(){return this._isComplete},get_completedSynchronously:function(){return this._completedSynchronously},get_exception:function(){return this._exception},get_throwExceptions:function(){return this._throwExceptions},set_throwExceptions:function(t){this._throwExceptions=t},get_delay:function(){return this._delay},set_delay:function(t){this._delay=t},post:function(t){for(var e=[],l=0;l<arguments.length;l++)e[l]=arguments[l];this.beginPost(e,null,null)},beginPost:function(t,e,l){if(this.cancel(),this._callArgs=Array.clone(t||[]),this._completeCallback=e,this._errorCallback=l,this._delay==-1)try{this._oncomplete()}finally{this._completedSynchronously=!0}else this._timer=setTimeout(this._oncomplete$delegate,this._delay)},cancel:function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._callArgs=null,this._isComplete=!1,this._asyncResult=null,this._completeCallback=null,this._errorCallback=null,this._exception=null,this._completedSynchronously=!1},call:function(t){for(var e=[],l=0;l<arguments.length;l++)e[l]=arguments[l];this.cancel(),this._callArgs=e,this._completeCallback=null,this._errorCallback=null;try{this._oncomplete()}finally{this._completedSynchronously=!0}if(this._exception)throw this._exception;return this._asyncResult},complete:function(){if(this._timer){try{this._oncomplete()}finally{this._completedSynchronously=!0}return this._asyncResult}if(this._isComplete)return this._asyncResult},_oncomplete:function(){var t=this._callArgs,e=this._completeCallback,l=this._errorCallback;this.cancel();try{t?this._asyncResult=this._callback.apply(this._context,t):this._asyncResult=this._callback.call(this._context),this._isComplete=!0,this._completedSynchronously=!1,e&&e(this)}catch(t){if(this._isComplete=!0,this._completedSynchronously=!1,this._exception=t,l&&l(this))return;if(this._throwExceptions)throw t}}},Sys.Extended.UI.DeferredOperation.registerClass("Sys.Extended.UI.DeferredOperation"); |