/[EmuXPortal]/trunk/EmuXPortal/Form1.cs
ViewVC logotype

Diff of /trunk/EmuXPortal/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/EmuXPortal/Form1.cs	2012/08/23 04:47:35	126
+++ trunk/EmuXPortal/Form1.cs	2012/10/04 21:52:13	137
@@ -367,6 +367,7 @@
         //}
         #region gameWorker
         private static Image DefaultGameImage = Properties.Resources.DefaultGameImage;
+        private object gameimage_lock = new object();
         private void gameWorker_DoWork(object sender, DoWorkEventArgs e)
         {
             Stopwatch t = e.Argument as Stopwatch;
@@ -394,8 +395,18 @@
                 game_ctrl.Dock = DockStyle.Top;
                 game_ctrl.Width = this.Width - 10;
                 game_ctrl.Tag = config;
-                game_ctrl.GameImage = config.RomImage == null ? DefaultGameImage : (Image)config.RomImage.Clone();
-                config.ReleaseRomImageResource();
+                try
+                {
+                    lock (gameimage_lock)
+                    {
+                        game_ctrl.GameImage = config.RomImage == null ? (Image)DefaultGameImage.Clone() : (Image)config.RomImage.Clone();
+                        config.ReleaseRomImageResource();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                }                
                 game_ctrl.GameName = config.RomTitle;
                 game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
                 game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
@@ -428,6 +439,7 @@
         #endregion
         #region platformWorker
         private static Image DefaultPlatformImage = Properties.Resources.DefaultPlatformImage;
+        private object platformimage_lock = new object();
         private void platformWorker_DoWork(object sender, DoWorkEventArgs e)
         {
             Stopwatch t = e.Argument as Stopwatch;
@@ -451,8 +463,18 @@
                 platform_ctrl.Dock = DockStyle.Top;
                 platform_ctrl.Width = this.Width - 10;
                 platform_ctrl.Tag = config;
-                platform_ctrl.PlatformImage = config.PlatformImage == null ? DefaultPlatformImage : (Image)config.PlatformImage.Clone();
-                config.ReleasePlatformImageResource();
+                try
+                {
+                    lock (platformimage_lock)
+                    {
+                        platform_ctrl.PlatformImage = config.PlatformImage == null ? DefaultPlatformImage : (Image)config.PlatformImage.Clone();
+                        config.ReleasePlatformImageResource();
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw ex;
+                } 
                 platform_ctrl.PlatformName = config.ToString();
                 platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
                 platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);

 

  ViewVC Help
Powered by ViewVC 1.1.22