/// <summary> /// /// </summary> /// <param name="serialNumber"></param> /// <returns></returns> public static Boolean Load(Int32 serialNumber) { if (_fileManager == null) { throw new InvalidOperationException("Progress class not initialized"); } try { // Get the storage device for the player IStorageDevice storage = _fileManager.GetStorageDevice(FileLocationContainer.Player); // Wait until storage container is ready and load the file if (SpinWait.SpinUntil(() => { Thread.MemoryBarrier(); return(storage.IsReady); }, Progress.FileOperationTimeout)) { if (storage.FileExists(".", String.Format(DefaultFileName, serialNumber))) { storage.Load(".", String.Format(DefaultFileName, serialNumber), Load); return(true); } } } catch (Exception) { // Load default if nothing was loaded LoadDefault(serialNumber); } return(false); }
/// <summary> /// Loads the settings from file /// </summary> /// <param name="name"></param> public static Boolean Load() { if (_fileManager == null) { throw new InvalidOperationException("Settings class not initialized"); } try { #if SILVERLIGHT // Get the storage device for the player IStorageDevice storage = _fileManager.GetStorageDevice(FileLocationContainer.Isolated); // Wait until storage container is ready and save the file Boolean timeout = false; Timer timer = new Timer((a) => timeout = true, null, Settings.FileOperationTimeout, System.Threading.Timeout.Infinite); while (!storage.IsReady && !timeout) { Thread.SpinWait(1000); Thread.MemoryBarrier(); } if (timeout) { throw new Exception("Timeout"); } if (storage.FileExists(".", DefaultFileName)) { storage.Load(".", Settings.DefaultFileName, Load); return(true); } #else // Get the storage device for the player IStorageDevice storage = _fileManager.GetStorageDevice(FileLocationContainer.Player); // Wait until storage container is ready and save the file if (SpinWait.SpinUntil(() => { Thread.MemoryBarrier(); return(storage.IsReady); }, Settings.FileOperationTimeout)) { if (storage.FileExists(".", DefaultFileName)) { storage.Load(".", Settings.DefaultFileName, Load); return(true); } } #endif } catch (Exception) { // Load default if nothing was loaded LoadDefault(); } return(false); }