diff --git a/Library/DirectSound.cs b/Library/DirectSound.cs index f1e58d0..bdcca4d 100644 --- a/Library/DirectSound.cs +++ b/Library/DirectSound.cs @@ -29,9 +29,12 @@ public void Dispose() public void SetVolume(double volume) { int attenuation = (volume < 0.01) ? (int)BufferVolume.Min : (int)Math.Floor(100 * 20 * Math.Log10(volume)); // 100 db - if (_buffer != null) + lock (_bufferLock) { - _buffer.SetVolume(attenuation); + if (_buffer != null) + { + _buffer.SetVolume(attenuation); + } } } @@ -116,11 +119,14 @@ private void UpdateBuffer(int offset, int count, BufferLock flags, Action _updater; private AutoResetEvent _position1Event = new AutoResetEvent(false); diff --git a/Library/Silverlight/ApplicationBase.cs b/Library/Silverlight/ApplicationBase.cs index 308f988..7629b24 100644 --- a/Library/Silverlight/ApplicationBase.cs +++ b/Library/Silverlight/ApplicationBase.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.Text; using System.Windows; #if WINDOWS_PHONE @@ -24,6 +25,17 @@ public ApplicationBase(string name) //AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnhandledException; } +#if !WINDOWS_PHONE + protected void InitializeOutOfBrowserUpdate() + { + if (IsRunningOutOfBrowser) + { + CheckAndDownloadUpdateCompleted += OnApplicationCheckAndDownloadUpdateCompleted; + CheckAndDownloadUpdateAsync(); + } + } +#endif + #if WINDOWS_PHONE protected void InitializePhoneApplication() { @@ -53,6 +65,27 @@ private string GetExceptionCaption(string title, bool isTerminating = false) return caption.ToString(); } +#if !WINDOWS_PHONE + private void OnApplicationCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e) + { + if (e.Error != null) + { + if (e.Error is PlatformNotSupportedException) + { + MessageBox.Show("An application update is available, but it requires the latest version of Silverlight."); + } + else if (Debugger.IsAttached) + { + Debugger.Break(); + } + } + else if (e.UpdateAvailable) + { + MessageBox.Show("An application update was downloaded. Restart the application to run the latest version."); + } + } +#endif + private void OnApplicationUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { MessageBox.Show(e.ExceptionObject.ToString(), GetExceptionCaption("Application Exception"), MessageBoxButton.OK); diff --git a/Virtu/Silverlight/MainApp.xaml.cs b/Virtu/Silverlight/MainApp.xaml.cs index 6054ff5..a13a6b2 100644 --- a/Virtu/Silverlight/MainApp.xaml.cs +++ b/Virtu/Silverlight/MainApp.xaml.cs @@ -8,6 +8,7 @@ public MainApp() : base("Virtu") { InitializeComponent(); + InitializeOutOfBrowserUpdate(); } } }