Files
SIG/Scripts/AjaxControlToolkit/Release/Common.Threading.js
rrene 927295c7ba Revert "-- corr"
This reverts commit 5315c47fcd.
2024-11-05 10:55:34 -07:00

1 line
2.5 KiB
JavaScript

Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.DeferredOperation=function(n,t,i){this._delay=n;this._context=t;this._callback=i;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 this._timer!=null},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(n){this._throwExceptions=n},get_delay:function(){return this._delay},set_delay:function(n){this._delay=n},post:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.beginPost(t,null,null)},beginPost:function(n,t,i){if(this.cancel(),this._callArgs=Array.clone(n||[]),this._completeCallback=t,this._errorCallback=i,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(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.cancel();this._callArgs=t;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 n=this._callArgs,t=this._completeCallback,i=this._errorCallback;this.cancel();try{this._asyncResult=n?this._callback.apply(this._context,n):this._callback.call(this._context);this._isComplete=!0;this._completedSynchronously=!1;t&&t(this)}catch(r){if(this._isComplete=!0,this._completedSynchronously=!1,this._exception=r,i&&i(this))return;if(this._throwExceptions)throw r;}}};Sys.Extended.UI.DeferredOperation.registerClass("Sys.Extended.UI.DeferredOperation");