Invokes an action after a delay times out (cancelling any previous actions that may be pending).
This can be used to invoke something after a series of rapid events have fired, like key-strokes or window size changed.
Inheritance: IDisposable
        /// <summary>Constructor.</summary>
        static GlobalEvents()
        {
            // Setup initial conditions.
            windowResizeDelay = new DelayedAction(ResizeDelay, FireWindowResizeComplete);
            panelResizeDelay = new DelayedAction(ResizeDelay, FirePanelResizeComplete);

            // Bind to window resize.
            jQuery.OnDocumentReady(delegate
                                       {
                                           jQuery.Window.Bind(DomEvents.Resize, delegate(jQueryEvent e) { FireWindowResize(); });
                                       });

            // Wire up events.
            WindowResize += delegate { windowResizeDelay.Start(); };
            PanelResized += delegate { panelResizeDelay.Start(); };
        }
        /// <summary>Downloads the resources defined for the package.</summary>
        /// <param name="onScriptsDownloaded">Invoked when the scripts have completed downloading.</param>
        /// <param name="onTimedOut">Invoked when/if the operation times out (NB: 'onScriptsDownloaded' is never called if the operation times out).</param>
        protected void DownloadInternal(Action onScriptsDownloaded, Action onTimedOut)
        {
            // Setup initial conditions.
            TimedOut = false;
            IsLoading = true;

            // Insert resources.
            InsertCssLinks();
            // TODO - Extend to include all resource types (images + CSS).

            // Setup failure timeout.
            DelayedAction timeout = new DelayedAction(DownloadTimeout, delegate
                                    {
                                        TimedOut = true;
                                        IsLoading = false;
                                        Helper.Invoke(onTimedOut);
                                    });
            timeout.Start();

            // Download the scripts
            DownloadScripts(delegate
                                {
                                    if (!TimedOut) // Only invoke if the timeout hasn't elapsed before this callback.
                                    {
                                        Helper.Invoke(onScriptsDownloaded);
                                    }
                                    timeout.Dispose();
                                    IsLoading = false;
                                });
        }
 /// <summary>Invokes the given action after the specified delay.</summary>
 /// <param name="delay">The delay (in seconds) before invoking the action.</param>
 /// <param name="action">The action to invoke.</param>
 /// <remarks>Returns the 'DelayedAction' used to invoke the method (can be used to cancel the delayed invoke operation).</remarks>
 public static DelayedAction Invoke(double delay, Action action)
 {
     DelayedAction delayedAction = new DelayedAction(delay, action);
     delayedAction.Start();
     return delayedAction;
 }