// Name: Common.Threading.debug.js // Assembly: AjaxControlToolkit // Version: 4.5.7.1213 // FileVersion: 4.5.7.1213 // (c) 2010 CodePlex Foundation /// /// /// (function() { var scriptName = "ExtendedThreading"; function execute() { var version = Sys.version; if (!version && !Sys._versionChecked) { Sys._versionChecked = true; throw new Error("AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll."); } Type.registerNamespace('Sys.Extended.UI'); Sys.Extended.UI.DeferredOperation = function(delay, context, callback) { /// /// Used to define a cancellable async operation /// /// the number of milliseconds to delay execution /// an object used as the context for the callback method /// The callback method to execute at the end of the delay this._delay = delay; this._context = context; this._callback = callback; this._completeCallback = null; this._errorCallback = null; this._timer = null; this._callArgs = null; this._isComplete = false; this._completedSynchronously = false; this._asyncResult = null; this._exception = null; this._throwExceptions = true; this._oncomplete$delegate = Function.createDelegate(this, this._oncomplete); this.post = Function.createDelegate(this, this.post); } Sys.Extended.UI.DeferredOperation.prototype = { get_isPending : function() { /// /// Gets whether there is an asynchronous operation pending /// /// return (this._timer != null); }, get_isComplete : function() { /// /// Gets whether the asynchronous operation has completed /// /// return this._isComplete; }, get_completedSynchronously : function() { /// /// Gets whether the operation completed synchronously /// /// return this._completedSynchronously; }, get_exception : function() { /// /// Gets the current exception if there is one /// /// return this._exception; }, get_throwExceptions : function() { /// /// Gets whether to throw exceptions /// /// return this._throwExceptions; }, set_throwExceptions : function(value) { /// /// Sets whether to throw exceptions /// /// True if exceptions should be thrown, otherwise false this._throwExceptions = value; }, get_delay : function() { /// /// Gets the current delay in milliseconds /// /// return this._delay; }, set_delay : function(value) { /// /// Sets the current delay in milliseconds /// /// The delay in milliseconds this._delay = value; }, post : function(args) { /// /// A method that can be directly attached to a delegate /// /// The arguments to the method var ar = []; for (var i = 0; i < arguments.length; i++) { ar[i] = arguments[i]; } this.beginPost(ar, null, null); }, beginPost : function(args, completeCallback, errorCallback) { /// /// Posts a call to an async operation on this port /// /// An array of arguments to the method /// The callback to execute after the delayed function completes /// The callback to execute in the event of an exception in the delayed function this.cancel(); this._callArgs = Array.clone(args || []); this._completeCallback = completeCallback; this._errorCallback = errorCallback; if (this._delay == -1) { try { this._oncomplete(); } finally { this._completedSynchronously = true; } } else { this._timer = setTimeout(this._oncomplete$delegate, this._delay); } }, cancel : function() { /// /// Cancels a pending post /// if (this._timer) { clearTimeout(this._timer); this._timer = null; } this._callArgs = null; this._isComplete = false; this._asyncResult = null; this._completeCallback = null; this._errorCallback = null; this._exception = null; this._completedSynchronously = false; }, call : function(args) { /// /// Executes the deferred operation synchronously /// /// The arguments to the method var ar = []; for (var i = 0; i < arguments.length; i++) { ar[i] = arguments[i]; } this.cancel(); this._callArgs = ar; this._completeCallback = null; this._errorCallback = null; try { this._oncomplete(); } finally { this._completedSynchronously = true; } if (this._exception) { throw this._exception; } return this._asyncResult; }, complete : function() { /// /// Completes a pending post synchronously /// if (this._timer) { try { this._oncomplete(); } finally { this._completedSynchronously = true; } return this._asyncResult; } else if (this._isComplete) { return this._asyncResult; } }, _oncomplete : function() { /// /// Completes a pending post asynchronously /// var args = this._callArgs; var completeCallback = this._completeCallback; var errorCallback = this._errorCallback; this.cancel(); try { if (args) { this._asyncResult = this._callback.apply(this._context, args); } else { this._asyncResult = this._callback.call(this._context); } this._isComplete = true; this._completedSynchronously = false; if (completeCallback) { completeCallback(this); } } catch (e) { this._isComplete = true; this._completedSynchronously = false; this._exception = e; if (errorCallback) { if (errorCallback(this)) { return; } } if (this._throwExceptions) { throw e; } } } } Sys.Extended.UI.DeferredOperation.registerClass("Sys.Extended.UI.DeferredOperation"); } // execute if (window.Sys && Sys.loader) { Sys.loader.registerScript(scriptName, ["Core"], execute); } else { execute(); } })();