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;
});
}