void ReloadFromServer(LoadingPanel loadingPanel) { if (Reloading != null) { Reloading(this, EventArgs.Empty); } WebServices.Instance.ReloadFromServer( () => { Action onComplete = () => { Action runScripts = () => { try { ScriptManager.Instance.RunScripts(); if (ScriptsStarted != null) { ScriptsStarted(this, EventArgs.Empty); } } catch (Exception x) { if (LaunchFailed != null) { #if WINDOWS_UWP LaunchFailed(this, EventArgs.Empty); #else LaunchFailed(this, new UnhandledExceptionEventArgs(x, false)); #endif } } }; if (loadingPanel) { loadingPanel.OnClose = () => { runScripts(); }; loadingPanel.MediaReady(); } else { runScripts(); } }; if (m_onLoadActions.Count > 0) { BatchProcessor iter = new BatchProcessor(m_onLoadActions.Count); iter.OnComplete(onComplete); foreach (var action in m_onLoadActions) { action(() => { iter++; }); } } else { onComplete(); } Platform.Instance.DownloadsComplete(); }, (reason) => { loadingPanel.DownloadError(reason); }); }