[mapguide-commits] r8750 - in trunk/Tools/Maestro: MgCooker OSGeo.MapGuide.MaestroAPI/Tile

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Aug 18 08:32:49 PDT 2015


Author: jng
Date: 2015-08-18 08:32:49 -0700 (Tue, 18 Aug 2015)
New Revision: 8750

Modified:
   trunk/Tools/Maestro/MgCooker/Program.cs
   trunk/Tools/Maestro/MgCooker/Progress.cs
   trunk/Tools/Maestro/MgCooker/SetupRun.cs
   trunk/Tools/Maestro/MgCooker/Strings.Designer.cs
   trunk/Tools/Maestro/MgCooker/Strings.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs
Log:
MgCooker tidy-up:
 - #2565: Use proper event handler delegate convention (Take 2 parameters: object sender, TEventArgs args where TEventArgs : System.EventArgs) for our various tile generator events
 - Don't start a build or script generation if no actual maps or tilesets have been selected.

Modified: trunk/Tools/Maestro/MgCooker/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Program.cs	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/MgCooker/Program.cs	2015-08-18 15:32:49 UTC (rev 8750)
@@ -67,20 +67,20 @@
             //basegroups="x","y"
             //extentoverride=minx,miny,maxx,maxy
 
-            Boolean cmdLineMode = false;
+            bool cmdLineMode = false;
 
-            string mapdefinitions = "";
-            string scaleindex = "";
-            string basegroups = "";
+            string mapdefinitions = string.Empty;
+            string scaleindex = string.Empty;
+            string basegroups = string.Empty;
 
-            string limitRows = "";
-            string limitCols = "";
+            string limitRows = string.Empty;
+            string limitCols = string.Empty;
 
-            string tileWidth = "";
-            string tileHeight = "";
+            string tileWidth = string.Empty;
+            string tileHeight = string.Empty;
 
-            string DPI = "";
-            string metersPerUnit = "";
+            string DPI = string.Empty;
+            string metersPerUnit = string.Empty;
 
             IEnvelope overrideExtents = null;
 
@@ -275,17 +275,16 @@
             }
             else
             {
-                bx.BeginRenderingMap += new ProgressCallback(bx_BeginRenderingMap);
-                bx.FinishRenderingMap += new ProgressCallback(bx_FinishRenderingMap);
-                bx.BeginRenderingGroup += new ProgressCallback(bx_BeginRenderingGroup);
-                bx.FinishRenderingGroup += new ProgressCallback(bx_FinishRenderingGroup);
-                bx.BeginRenderingScale += new ProgressCallback(bx_BeginRenderingScale);
-                bx.FinishRenderingScale += new ProgressCallback(bx_FinishRenderingScale);
-                bx.BeginRenderingTile += new ProgressCallback(bx_BeginRenderingTile);
-                bx.FinishRenderingTile += new ProgressCallback(bx_FinishRenderingTile);
+                bx.BeginRenderingMap += OnBeginRenderingMap;
+                bx.FinishRenderingMap += OnFinishRenderingMap;
+                bx.BeginRenderingGroup += OnBeginRenderingGroup;
+                bx.FinishRenderingGroup += OnFinishRenderingGroup;
+                bx.BeginRenderingScale += OnBeginRenderingScale;
+                bx.FinishRenderingScale += OnFinishRenderingScale;
+                bx.BeginRenderingTile += OnBeginRenderingTile;
+                bx.FinishRenderingTile += OnFinishRenderingTile;
+                bx.FailedRenderingTile += OnFailedRenderingTile;
 
-                bx.FailedRenderingTile += new ErrorCallback(bx_FailedRenderingTile);
-
                 mapCount = 0;
                 lastUpdate = DateTime.Now;
 
@@ -293,16 +292,24 @@
             }
         }
 
-        private static void bx_FailedRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref Exception exception)
+        private static void OnFailedRenderingTile(object sender, TileRenderingErrorEventArgs args)
         {
-            exceptionList.Add(exception);
-            exception = null;
+            if (args.Error != null)
+            {
+                exceptionList.Add(args.Error);
+                args.Error = null;
+            }
         }
 
-        private static void DisplayProgress(MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void DisplayProgress(object sender, TileProgressEventArgs args)
         {
             if (hasConsole)
                 Console.Clear();
+
+            var map = args.Map;
+            var group = args.Group;
+            var scaleindex = args.ScaleIndex;
+
             Console.WriteLine(string.Format(Strings.ConsoleUpdateTime.Replace("\\t", "\t"), DateTime.Now));
             Console.WriteLine(string.Format(Strings.ConsoleCurrentMap.Replace("\\t", "\t"), map.ResourceId, mapCount, map.Parent.Maps.Count));
             Console.WriteLine(string.Format(Strings.ConsoleCurrentGroup.Replace("\\t", "\t"), group, groupCount, map.TileSet.GroupCount));
@@ -319,27 +326,27 @@
             }
         }
 
-        private static void bx_FinishRenderingGroup(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnFinishRenderingGroup(object sender, TileProgressEventArgs args)
         {
             TimeSpan duration = DateTime.Now - beginGroup;
             if (m_loggableProgress)
-                Console.WriteLine(string.Format(Strings.ConsoleOperationFinishGroup, DateTime.Now, group, duration));
+                Console.WriteLine(string.Format(Strings.ConsoleOperationFinishGroup, DateTime.Now, args.Group, duration));
         }
 
-        private static void bx_BeginRenderingGroup(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnBeginRenderingGroup(object sender, TileProgressEventArgs args)
         {
             groupCount++;
             beginGroup = DateTime.Now;
 
             if (m_loggableProgress)
-                Console.WriteLine(string.Format(Strings.ConsoleOperationBeginGroup, beginGroup, group, 1, 1));
+                Console.WriteLine(string.Format(Strings.ConsoleOperationBeginGroup, beginGroup, args.Group, 1, 1));
 
             tileRuns = new List<TimeSpan>();
             tileCount = 0;
-            totalTiles = map.TotalTiles;
+            totalTiles = args.Map.TotalTiles;
         }
 
-        private static void bx_FinishRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnFinishRenderingTile(object sender, TileProgressEventArgs args)
         {
             tileRuns.Add(DateTime.Now - beginTile);
             tileCount++;
@@ -364,45 +371,45 @@
                 lastUpdate = DateTime.Now;
 
                 if (m_loggableProgress)
-                    Console.WriteLine(string.Format(Strings.ConsoleOperationFinishTile, tileCount, totalTiles, group, duration));
+                    Console.WriteLine(string.Format(Strings.ConsoleOperationFinishTile, tileCount, totalTiles, args.Group, duration));
                 else
-                    DisplayProgress(map, group, scaleindex, row, column, ref cancel);
+                    DisplayProgress(sender, args);
             }
         }
 
-        private static void bx_BeginRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnBeginRenderingTile(object sender, TileProgressEventArgs args)
         {
             beginTile = DateTime.Now;
         }
 
-        private static void bx_FinishRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnFinishRenderingScale(object sender, TileProgressEventArgs args)
         {
             TimeSpan duration = DateTime.Now - beginScale;
             if (m_loggableProgress)
-                Console.WriteLine(string.Format(Strings.ConsoleOperationFinishScale, DateTime.Now, map.TileSet.GetScaleAt(scaleindex), duration));
+                Console.WriteLine(string.Format(Strings.ConsoleOperationFinishScale, DateTime.Now, args.Map.TileSet.GetScaleAt(args.ScaleIndex), duration));
         }
 
-        private static void bx_BeginRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnBeginRenderingScale(object sender, TileProgressEventArgs args)
         {
             beginScale = DateTime.Now;
             if (m_loggableProgress)
-                Console.WriteLine(string.Format(Strings.ConsoleOperationBeginScale, beginMap, map.TileSet.GetScaleAt(scaleindex), scaleindex, map.Resolutions));
+                Console.WriteLine(string.Format(Strings.ConsoleOperationBeginScale, beginMap, args.Map.TileSet.GetScaleAt(args.ScaleIndex), args.ScaleIndex, args.Map.Resolutions));
         }
 
-        private static void bx_FinishRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnFinishRenderingMap(object sender, TileProgressEventArgs args)
         {
             groupCount = 0;
             TimeSpan duration = DateTime.Now - beginMap;
             if (m_loggableProgress)
-                Console.WriteLine(string.Format(Strings.ConsoleOperationFinishMap, DateTime.Now, map.ResourceId, duration));
+                Console.WriteLine(string.Format(Strings.ConsoleOperationFinishMap, DateTime.Now, args.Map.ResourceId, duration));
         }
 
-        private static void bx_BeginRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private static void OnBeginRenderingMap(object sender, TileProgressEventArgs args)
         {
             mapCount++;
             beginMap = DateTime.Now;
             if (m_loggableProgress)
-                Console.WriteLine(string.Format(Strings.ConsoleOperationBeginMap, beginMap, map.ResourceId));
+                Console.WriteLine(string.Format(Strings.ConsoleOperationBeginMap, beginMap, args.Map.ResourceId));
         }
     }
 }
\ No newline at end of file

Modified: trunk/Tools/Maestro/MgCooker/Progress.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Progress.cs	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/MgCooker/Progress.cs	2015-08-18 15:32:49 UTC (rev 8750)
@@ -56,27 +56,27 @@
             : this()
         {
             m_bx = bx;
-            bx.BeginRenderingMap += new ProgressCallback(bx_BeginRenderingMap);
-            bx.BeginRenderingGroup += new ProgressCallback(bx_BeginRenderingGroup);
-            bx.BeginRenderingScale += new ProgressCallback(bx_BeginRenderingScale);
-            bx.BeginRenderingTile += new ProgressCallback(bx_BeginRenderingTile);
-
-            bx.FinishRenderingTile += new ProgressCallback(bx_FinishRenderingTile);
-            bx.FinishRenderingMaps += new ProgressCallback(bx_FinishRenderingMaps);
-            bx.FailedRenderingTile += new ErrorCallback(bx_FailedRenderingTile);
+            bx.BeginRenderingMap += OnBeginRenderingMap;
+            bx.BeginRenderingGroup += OnBeginRenderingGroup;
+            bx.BeginRenderingScale += OnBeginRenderingScale;
+            bx.BeginRenderingTile += OnBeginRenderingTile;
+            bx.FinishRenderingTile += OnFinishRenderingTile;
+            bx.FinishRenderingMaps += OnFinishRenderingMaps;
+            bx.FailedRenderingTile += OnFailedRenderingTile;
             m_tileRuns = new List<TimeSpan>();
 
             m_grandTotalTiles = 0;
             foreach (MapTilingConfiguration bm in m_bx.Maps)
+            {
                 m_grandTotalTiles += bm.TotalTiles;
-
+            }
             m_grandBegin = DateTime.Now;
         }
 
-        private void bx_FailedRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref Exception exception)
+        private void OnFailedRenderingTile(object sender, TileRenderingErrorEventArgs args)
         {
             m_failCount++;
-            exception = null; //Eat it
+            args.Error = null; //Eat it
         }
 
         public TimeSpan TotalTime { get; private set; }
@@ -90,7 +90,7 @@
             this.Close();
         }
 
-        private void bx_FinishRenderingMaps(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private void OnFinishRenderingMaps(object sender, TileProgressEventArgs args)
         {
             if (this.InvokeRequired)
                 this.Invoke(new System.Threading.ThreadStart(DoClose));
@@ -98,7 +98,7 @@
                 DoClose();
         }
 
-        private void bx_FinishRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private void OnFinishRenderingTile(object sender, TileProgressEventArgs args)
         {
             m_tileRuns.Add(DateTime.Now - m_beginTile);
             m_tileCount++;
@@ -123,27 +123,31 @@
                 m_tileRuns.Clear();
                 m_lastUpdate = DateTime.Now;
 
-                DisplayProgress(map, group, scaleindex, row, column, ref cancel);
+                DisplayProgress(sender, args);
             }
         }
-
-        private delegate void DisplayProgressDelegate(MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel);
-
-        private void DisplayProgress(MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        
+        private void DisplayProgress(object sender, TileProgressEventArgs args)
         {
             if (m_cancel)
-                cancel = true;
+            {
+                args.Cancel = true;
+            }
 
             if (this.InvokeRequired)
-                this.Invoke(new DisplayProgressDelegate(DisplayProgress), new object[] { map, group, scaleindex, row, column, cancel });
+            {
+                ProgressCallback action = DisplayProgress;
+                this.Invoke(action, new object[] { sender, args });
+            }
             else
             {
-                label1.Text = string.Format(Strings.CurrentGroupStatus, group, map.ResourceId);
+                label1.Text = string.Format(Strings.CurrentGroupStatus, args.Group, args.Map.ResourceId);
 
                 tilePG.Value = (int)Math.Max(Math.Min((m_tileCount / (double)m_totalTiles) * (tilePG.Maximum - tilePG.Minimum), tilePG.Maximum), tilePG.Minimum);
                 totalPG.Value = (int)Math.Max(Math.Min((m_grandTotalTileCount / (double)m_grandTotalTiles) * (totalPG.Maximum - totalPG.Minimum), totalPG.Maximum), totalPG.Minimum);
 
-                this.Text = m_origTitle + " - (" + (int)(((double)m_grandTotalTileCount / (double)m_grandTotalTiles) * 100.0) + "%)";
+                var percentage = (int)(((double)m_grandTotalTileCount / (double)m_grandTotalTiles) * 100.0);
+                this.Text = $"{m_origTitle} - ({percentage}%)";
 
                 if (m_failCount == 0)
                     tileCounter.Text = string.Format(Strings.CurrentTileCounter, m_grandTotalTileCount, m_grandTotalTiles, string.Empty);
@@ -153,7 +157,7 @@
                 TimeSpan elapsed = DateTime.Now - m_grandBegin;
                 DateTime finish = DateTime.Now + (new TimeSpan(m_prevDuration.Ticks * m_grandTotalTiles) - elapsed);
                 TimeSpan remain = finish - DateTime.Now;
-                
+
                 if (finish < DateTime.Now)
                     finishEstimate.Text = Strings.InsufficientTimePassed;
                 else
@@ -161,30 +165,19 @@
             }
         }
 
-        private void bx_BeginRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
-        {
-            m_beginTile = DateTime.Now;
-        }
+        private void OnBeginRenderingTile(object sender, TileProgressEventArgs args) => m_beginTile = DateTime.Now;
 
-        private void bx_BeginRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
-        {
-        }
+        private void OnBeginRenderingScale(object sender, TileProgressEventArgs args) { }
 
-        private void bx_BeginRenderingGroup(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+        private void OnBeginRenderingGroup(object sender, TileProgressEventArgs args)
         {
-            m_totalTiles = map.TotalTiles;
+            m_totalTiles = args.Map.TotalTiles;
             m_tileCount = 0;
         }
 
-        private void bx_BeginRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
-        {
-            m_tileCount = 0;
-        }
+        private void OnBeginRenderingMap(object sender, TileProgressEventArgs args) => m_tileCount = 0;
 
-        private void BeginRendering()
-        {
-            m_bx.RenderAll();
-        }
+        private void BeginRendering() => m_bx.RenderAll();
 
         private void Progress_Load(object sender, EventArgs e)
         {

Modified: trunk/Tools/Maestro/MgCooker/SetupRun.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/SetupRun.cs	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/MgCooker/SetupRun.cs	2015-08-18 15:32:49 UTC (rev 8750)
@@ -197,7 +197,7 @@
                     TreeNode mn = MapTree.Nodes.Add(m);
 
                     mn.ImageIndex = mn.SelectedImageIndex = 0;
-                    mn.Tag = mdef;
+                    mn.Tag = (object)mdef ?? (object)tsd;
                     foreach (var g in tileSet.BaseMapLayerGroups)
                     {
                         TreeNode gn = mn.Nodes.Add(g.Name);
@@ -233,10 +233,7 @@
             MapTree_AfterSelect(null, null);
         }
 
-        private void btnClose_Click(object sender, EventArgs e)
-        {
-            this.Close();
-        }
+        private void btnClose_Click(object sender, EventArgs e) => this.Close();
 
         private void btnBuild_Click(object sender, EventArgs e)
         {
@@ -267,6 +264,12 @@
                     bx.Maps.Add(bm);
                 }
 
+                if (bx.Maps.Count == 0)
+                {
+                    MessageBox.Show(Strings.NoMapsOrTileSetsSelected);
+                    return;
+                }
+
                 Progress p = new Progress(bx);
                 if (p.ShowDialog(this) != DialogResult.Cancel)
                 {
@@ -324,20 +327,11 @@
             }
         }
 
-        static void PushArg(List<string> args, string name, string value)
-        {
-            args.Add($"--{name}=\"{value}\""); //NOXLATE
-        }
+        static void PushArg(List<string> args, string name, string value) => args.Add($"--{name}=\"{value}\""); //NOXLATE
 
-        static void PushArgUnquoted(List<string> args, string name, string value)
-        {
-            args.Add($"--{name}={value}"); //NOXLATE
-        }
+        static void PushArgUnquoted(List<string> args, string name, string value) => args.Add($"--{name}={value}"); //NOXLATE
 
-        static void PushSwitch(List<string> args, string name)
-        {
-            args.Add($"--{name}"); //NOXLATE
-        }
+        static void PushSwitch(List<string> args, string name) => args.Add($"--{name}"); //NOXLATE
 
         private void btnSaveScript_Click(object sender, EventArgs e)
         {
@@ -348,6 +342,13 @@
                     string.Format(Strings.FileTypeAllFiles + "|{0}", "*.*"); //NOXLATE
             }
 
+            var configs = ReadTree();
+            if (configs.Count == 0)
+            {
+                MessageBox.Show(Strings.NoMapsOrTileSetsSelected);
+                return;
+            }
+
             if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
             {
                 //Common args for all map defintions to be tiled
@@ -404,7 +405,7 @@
                         sw.WriteLine($"pushd \"{exePath}\""); //NOXLATE
                     }
 
-                    foreach (Config c in ReadTree())
+                    foreach (Config c in configs)
                     {
                         //Map-specific args
                         List<string> argsMap = new List<string>();
@@ -506,10 +507,7 @@
             }
         }
 
-        private void LimitTileset_CheckedChanged(object sender, EventArgs e)
-        {
-            TilesetLimitPanel.Enabled = LimitTileset.Checked;
-        }
+        private void LimitTileset_CheckedChanged(object sender, EventArgs e) => TilesetLimitPanel.Enabled = LimitTileset.Checked;
 
         private void MapTree_AfterSelect(object sender, TreeViewEventArgs e)
         {
@@ -529,7 +527,8 @@
                     root = root.Parent;
 
                 IEnvelope box;
-                box = m_coordinateOverrides.ContainsKey(root.Text) ? m_coordinateOverrides[root.Text] : ((IMapDefinition)root.Tag).Extents;
+
+                box = m_coordinateOverrides.ContainsKey(root.Text) ? m_coordinateOverrides[root.Text] : GetExtents(root);
                 BoundsOverride.Tag = root;
 
                 try
@@ -549,6 +548,13 @@
             }
         }
 
+        private IEnvelope GetExtents(TreeNode root)
+        {
+            IMapDefinition mdf = root.Tag as IMapDefinition;
+            ITileSetDefinition tsd = root.Tag as ITileSetDefinition;
+            return mdf?.Extents ?? tsd?.Extents;
+        }
+
         private void ResetBounds_Click(object sender, EventArgs e)
         {
             if (BoundsOverride.Tag as TreeNode == null)

Modified: trunk/Tools/Maestro/MgCooker/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Strings.Designer.cs	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/MgCooker/Strings.Designer.cs	2015-08-18 15:32:49 UTC (rev 8750)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.34209
+//     Runtime Version:4.0.30319.42000
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -333,6 +333,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to You have no selected any Map Definitions or Tile Sets.
+        /// </summary>
+        internal static string NoMapsOrTileSetsSelected {
+            get {
+                return ResourceManager.GetString("NoMapsOrTileSetsSelected", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Could not determine any method to calculate meters per unit.
         /// </summary>
         internal static string NoMethodToCalculateMpu {

Modified: trunk/Tools/Maestro/MgCooker/Strings.resx
===================================================================
--- trunk/Tools/Maestro/MgCooker/Strings.resx	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/MgCooker/Strings.resx	2015-08-18 15:32:49 UTC (rev 8750)
@@ -233,6 +233,9 @@
   <data name="NoMapSelected" xml:space="preserve">
     <value>No Map Definition selected</value>
   </data>
+  <data name="NoMapsOrTileSetsSelected" xml:space="preserve">
+    <value>You have no selected any Map Definitions or Tile Sets</value>
+  </data>
   <data name="NoMethodToCalculateMpu" xml:space="preserve">
     <value>Could not determine any method to calculate meters per unit</value>
   </data>

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs	2015-08-18 15:32:49 UTC (rev 8750)
@@ -29,29 +29,137 @@
 
 namespace OSGeo.MapGuide.MaestroAPI.Tile
 {
+    public class TileProgressEventArgs : EventArgs
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="state">The state that invoked the callback</param>
+        /// <param name="map">The map currently being processed</param>
+        /// <param name="group">The group being processed</param>
+        /// <param name="scaleindex">The scaleindex being processed</param>
+        /// <param name="row">The row being processed</param>
+        /// <param name="column">The column being processed</param>
+        /// <param name="cancel">A control flag to stop the tile rendering</param>
+        public TileProgressEventArgs(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, bool cancel)
+        {
+            this.State = state;
+            this.Map = map;
+            this.Group = group;
+            this.ScaleIndex = scaleindex;
+            this.Row = row;
+            this.Column = column;
+            this.Cancel = cancel;
+        }
+
+        /// <summary>
+        /// The state that invoked the callback
+        /// </summary>
+        public CallbackStates State { get; }
+
+        /// <summary>
+        /// The map currently being processed
+        /// </summary>
+        public MapTilingConfiguration Map { get; }
+
+        /// <summary>
+        /// The group being processed
+        /// </summary>
+        public string Group { get; }
+
+        /// <summary>
+        /// The scaleindex being processed
+        /// </summary>
+        public int ScaleIndex { get; }
+
+        /// <summary>
+        /// The row being processed
+        /// </summary>
+        public int Row { get; }
+
+        /// <summary>
+        /// The column being processed
+        /// </summary>
+        public int Column { get; }
+
+        /// <summary>
+        /// A control flag to stop the tile rendering
+        /// </summary>
+        public bool Cancel { get; set; }
+    }
+
+    public class TileRenderingErrorEventArgs : EventArgs
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="state">The state that invoked the callback</param>
+        /// <param name="map">The map currently being processed</param>
+        /// <param name="group">The group being processed</param>
+        /// <param name="scaleindex">The scaleindex being processed</param>
+        /// <param name="row">The row being processed</param>
+        /// <param name="column">The column being processed</param>
+        /// <param name="error"></param>
+        public TileRenderingErrorEventArgs(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, Exception error)
+        {
+            this.State = state;
+            this.Map = map;
+            this.Group = group;
+            this.ScaleIndex = scaleindex;
+            this.Row = row;
+            this.Column = column;
+            this.Error = error;
+        }
+
+        /// <summary>
+        /// The state that invoked the callback
+        /// </summary>
+        public CallbackStates State { get; }
+
+        /// <summary>
+        /// The map currently being processed
+        /// </summary>
+        public MapTilingConfiguration Map { get; }
+
+        /// <summary>
+        /// The group being processed
+        /// </summary>
+        public string Group { get; }
+
+        /// <summary>
+        /// The scaleindex being processed
+        /// </summary>
+        public int ScaleIndex { get; }
+
+        /// <summary>
+        /// The row being processed
+        /// </summary>
+        public int Row { get; }
+
+        /// <summary>
+        /// The column being processed
+        /// </summary>
+        public int Column { get; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public Exception Error { get; set; }
+    }
+
     /// <summary>
     /// This delegate is used to monitor progress on tile rendering
     /// </summary>
-    /// <param name="map">The map currently being processed</param>
-    /// <param name="group">The group being processed</param>
-    /// <param name="scaleindex">The scaleindex being processed</param>
-    /// <param name="row">The row being processed</param>
-    /// <param name="column">The column being processed</param>
-    /// <param name="cancel">A control flag to stop the tile rendering</param>
-    /// <param name="state">The state that invoked the callback</param>
-    public delegate void ProgressCallback(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel);
+    /// <param name="sender"></param>
+    /// <param name="args"></param>
+    public delegate void ProgressCallback(object sender, TileProgressEventArgs args);
 
     /// <summary>
     /// This delegate is used to monitor progress on tile rendering
     /// </summary>
-    /// <param name="map">The map currently being processed</param>
-    /// <param name="group">The group being processed</param>
-    /// <param name="scaleindex">The scaleindex being processed</param>
-    /// <param name="row">The row being processed</param>
-    /// <param name="column">The column being processed</param>
-    /// <param name="state">The state that invoked the callback</param>
-    /// <param name="exception">The exception from the last attempt, set this to null to ignore the exception</param>
-    public delegate void ErrorCallback(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref Exception exception);
+    /// <param name="sender"></param>
+    /// <param name="args"></param>
+    public delegate void ErrorCallback(object sender, TileRenderingErrorEventArgs args);
 
     /// <summary>
     /// These are the avalible states for callbacks
@@ -203,62 +311,69 @@
 
         internal void InvokeBeginRendering(MapTilingConfiguration batchMap)
         {
-            if (this.BeginRenderingMap != null)
-                this.BeginRenderingMap(CallbackStates.StartRenderMap, batchMap, null, -1, -1, -1, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.StartRenderMap, batchMap, null, -1, -1, -1, m_cancel);
+            this.BeginRenderingMap?.Invoke(this, args);
+            m_cancel = args.Cancel;
             PauseEvent.WaitOne();
         }
 
         internal void InvokeFinishRendering(MapTilingConfiguration batchMap)
         {
-            if (this.FinishRenderingMap != null)
-                this.FinishRenderingMap(CallbackStates.FinishRenderMap, batchMap, null, -1, -1, -1, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.FinishRenderMap, batchMap, null, -1, -1, -1, m_cancel);
+            this.FinishRenderingMap?.Invoke(this, args);
+            m_cancel = args.Cancel;
         }
 
         internal void InvokeBeginRendering(MapTilingConfiguration batchMap, string group)
         {
-            if (this.BeginRenderingGroup != null)
-                this.BeginRenderingGroup(CallbackStates.StartRenderGroup, batchMap, group, -1, -1, -1, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.StartRenderGroup, batchMap, group, -1, -1, -1, m_cancel);
+            this.BeginRenderingGroup?.Invoke(this, args);
+            m_cancel = args.Cancel;
             PauseEvent.WaitOne();
         }
 
         internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group)
         {
-            if (this.FinishRenderingGroup != null)
-                this.FinishRenderingGroup(CallbackStates.FinishRenderGroup, batchMap, group, -1, -1, -1, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.FinishRenderGroup, batchMap, group, -1, -1, -1, m_cancel);
+            this.FinishRenderingGroup?.Invoke(this, args);
+            m_cancel = args.Cancel;
         }
 
         internal void InvokeBeginRendering(MapTilingConfiguration batchMap, string group, int scaleindex)
         {
-            if (this.BeginRenderingScale != null)
-                this.BeginRenderingScale(CallbackStates.StartRenderScale, batchMap, group, scaleindex, -1, -1, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.StartRenderScale, batchMap, group, scaleindex, -1, -1, m_cancel);
+            this.BeginRenderingScale?.Invoke(this, args);
+            m_cancel = args.Cancel;
             PauseEvent.WaitOne();
         }
 
         internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group, int scaleindex)
         {
-            if (this.FinishRenderingScale != null)
-                this.FinishRenderingScale(CallbackStates.FinishRenderScale, batchMap, group, scaleindex, -1, -1, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.FinishRenderScale, batchMap, group, scaleindex, -1, -1, m_cancel);
+            this.FinishRenderingScale?.Invoke(this, args);
+            m_cancel = args.Cancel;
         }
 
         internal void InvokeBeginRendering(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col)
         {
-            if (this.BeginRenderingTile != null)
-                this.BeginRenderingTile(CallbackStates.StartRenderTile, batchMap, group, scaleindex, row, col, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.StartRenderTile, batchMap, group, scaleindex, row, col, m_cancel);
+            this.BeginRenderingTile?.Invoke(this, args);
+            m_cancel = args.Cancel;
             PauseEvent.WaitOne();
         }
 
         internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col)
         {
-            if (this.FinishRenderingTile != null)
-                this.FinishRenderingTile(CallbackStates.FinishRenderTile, batchMap, group, scaleindex, row, col, ref m_cancel);
+            var args = new TileProgressEventArgs(CallbackStates.FinishRenderTile, batchMap, group, scaleindex, row, col, m_cancel);
+            this.FinishRenderingTile?.Invoke(this, args);
+            m_cancel = args.Cancel;
         }
 
-        internal Exception InvokeError(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col, ref Exception exception)
+        internal Exception InvokeError(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col, Exception exception)
         {
-            if (this.FailedRenderingTile != null)
-                this.FailedRenderingTile(CallbackStates.FailedRenderingTile, batchMap, group, scaleindex, row, col, ref exception);
-
-            return exception;
+            var args = new TileRenderingErrorEventArgs(CallbackStates.FailedRenderingTile, batchMap, group, scaleindex, row, col, exception);
+            this.FailedRenderingTile?.Invoke(this, args);
+            return args.Error;
         }
 
         #endregion Events
@@ -308,7 +423,9 @@
             {
                 List<string> tmp = new List<string>();
                 foreach (var doc in m_connection.ResourceService.GetRepositoryResources(StringConstants.RootIdentifier, ResourceTypes.MapDefinition.ToString()).Children)
+                {
                     tmp.Add(doc.ResourceId);
+                }
                 maps = tmp.ToArray();
             }
 
@@ -324,40 +441,31 @@
         /// Sets the list of scale indexes
         /// </summary>
         /// <param name="scaleindexes"></param>
-        public void SetScales(int[] scaleindexes)
-        {
-            foreach (MapTilingConfiguration bm in m_maps)
-                bm.SetScales(scaleindexes);
-        }
+        public void SetScales(int[] scaleindexes) => m_maps.ForEach(bm => bm.SetScales(scaleindexes));
 
         /// <summary>
         /// Sets the list of groups
         /// </summary>
         /// <param name="groups"></param>
-        public void SetGroups(string[] groups)
-        {
-            foreach (MapTilingConfiguration bm in m_maps)
-                bm.SetGroups(groups);
-        }
+        public void SetGroups(string[] groups) => m_maps.ForEach(bm => bm.SetGroups(groups));
 
         /// <summary>
         /// Limits the number of rows
         /// </summary>
         /// <param name="limit"></param>
-        public void LimitRows(long limit)
-        {
-            foreach (MapTilingConfiguration bm in m_maps)
-                bm.LimitRows(limit);
-        }
+        public void LimitRows(long limit) => m_maps.ForEach(bm => bm.LimitRows(limit));
 
         /// <summary>
         /// Limits the number of columns
         /// </summary>
         /// <param name="limit"></param>
-        public void LimitCols(long limit)
+        public void LimitCols(long limit) => m_maps.ForEach(bm => bm.LimitCols(limit));
+
+        private static void TriggerEvent(ProgressCallback evt, object sender, CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
         {
-            foreach (MapTilingConfiguration bm in m_maps)
-                bm.LimitCols(limit);
+            var args = new TileProgressEventArgs(state, map, group, scaleindex, row, column, cancel);
+            evt?.Invoke(sender, args);
+            cancel = args.Cancel;
         }
 
         /// <summary>
@@ -367,17 +475,15 @@
         {
             m_cancel = false;
 
-            if (this.BeginRenderingMaps != null)
-                this.BeginRenderingMaps(CallbackStates.StartRenderAllMaps, null, null, -1, -1, -1, ref m_cancel);
-
+            TriggerEvent(this.BeginRenderingMaps, this, CallbackStates.StartRenderAllMaps, null, null, -1, -1, -1, ref m_cancel);
             foreach (MapTilingConfiguration bm in this.Maps)
+            {
                 if (m_cancel)
                     break;
                 else
                     bm.Render();
-
-            if (this.FinishRenderingMaps != null)
-                this.FinishRenderingMaps(CallbackStates.FinishRenderAllMaps, null, null, -1, -1, -1, ref m_cancel);
+            }
+            TriggerEvent(this.FinishRenderingMaps, this, CallbackStates.FinishRenderAllMaps, null, null, -1, -1, -1, ref m_cancel);
         }
 
         /// <summary>
@@ -625,8 +731,10 @@
             //TODO: Re-read scales from mapdef?
             SortedList<int, int> s = new SortedList<int, int>();
             foreach (int i in scaleindexes)
+            {
                 if (!s.ContainsKey(i))
                     s.Add(i, i);
+            }
 
             List<int> keys = new List<int>(s.Keys);
             keys.Reverse();
@@ -642,19 +750,25 @@
             //Preserve the original scales
             m_scaleindexmap = new int[keys.Count];
             for (int i = 0; i < keys.Count; i++)
+            {
                 m_scaleindexmap[i] = keys[i];
+            }
         }
 
         internal void LimitCols(long limit)
         {
             foreach (long[] d in m_dimensions)
+            {
                 d[1] = Math.Min(limit, d[1]);
+            }
         }
 
         internal void LimitRows(long limit)
         {
             foreach (long[] d in m_dimensions)
+            {
                 d[0] = Math.Min(limit, d[0]);
+            }
         }
 
         /// <summary>
@@ -666,7 +780,9 @@
             {
                 long t = 0;
                 foreach (long[] d in m_dimensions)
+                {
                     t += d[0] * d[1];
+                }
                 return t;
             }
         }
@@ -725,10 +841,12 @@
             if (!m_parent.Cancel)
             {
                 for (int i = this.Resolutions - 1; i >= 0; i--)
+                {
                     if (m_parent.Cancel)
                         break;
                     else
                         RenderScale(i, group);
+                }
             }
 
             m_parent.InvokeFinishRendering(this, group);
@@ -742,12 +860,15 @@
             m_parent.InvokeBeginRendering(this);
 
             if (!m_parent.Cancel)
+            {
                 foreach (string s in m_groups)
+                {
                     if (m_parent.Cancel)
                         break;
                     else
                         RenderGroup(s);
-
+                }
+            }
             m_parent.InvokeFinishRendering(this);
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs	2015-08-18 13:46:44 UTC (rev 8749)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs	2015-08-18 15:32:49 UTC (rev 8750)
@@ -38,12 +38,12 @@
                 Error
             }
 
-            public EventType Type;
-            public int Col;
-            public int Row;
-            public Exception Exception;
-            public EventWaitHandle Event;
-            public object Result = null;
+            public EventType Type { get; }
+            public int Col { get; }
+            public int Row { get; }
+            public Exception Exception { get; }
+            public EventWaitHandle Event { get; }
+            public object Result { get; set; }
 
             public EventPassing(EventType type, int row, int col, Exception ex, EventWaitHandle @event)
             {
@@ -55,53 +55,50 @@
             }
         }
 
-        public Queue<KeyValuePair<int, int>> TileSet;
-        private readonly Queue<EventPassing> RaiseEvents = new Queue<EventPassing>();
-        private readonly object SyncLock;
-        private readonly AutoResetEvent Event;
-        private int CompleteFlag;
-        private readonly TilingRunCollection Parent;
-        private int Scale;
-        private string Group;
-        private readonly string MapDefinition;
-        private MapTilingConfiguration Invoker;
+        public Queue<KeyValuePair<int, int>> TileSet { get; }
 
-        private bool Randomize;
-        private int Rows;
-        private int Cols;
-        private int RowOffset;
-        private int ColOffset;
+        private readonly Queue<EventPassing> _raiseEvents = new Queue<EventPassing>();
+        private readonly object _syncLock;
+        private readonly AutoResetEvent _event;
+        private readonly TilingRunCollection _parent;
+        private readonly int _scale;
+        private readonly string _group;
+        private readonly string _mapDefinition;
+        private readonly MapTilingConfiguration _invoker;
+        private readonly bool _randomize;
+        private readonly int _rows;
+        private readonly int _cols;
+        private readonly int _rowOffset;
+        private readonly int _colOffset;
 
-        private bool FillerComplete = false;
+        private bool _fillerComplete = false;
+        private int _completeFlag;
 
         public RenderThreads(MapTilingConfiguration invoker, TilingRunCollection parent, int scale, string group, string mapdef, int rows, int cols, int rowOffset, int colOffset, bool randomize)
         {
-            TileSet = new Queue<KeyValuePair<int, int>>();
-            SyncLock = new object();
-            Event = new AutoResetEvent(false);
-            CompleteFlag = parent.Config.ThreadCount;
-            RaiseEvents = new Queue<EventPassing>();
-            this.Scale = scale;
-            this.Group = group;
-            this.Parent = parent;
-            this.MapDefinition = mapdef;
-            this.Invoker = invoker;
-            Randomize = randomize;
-            Rows = rows;
-            Cols = cols;
-            this.RowOffset = rowOffset;
-            this.ColOffset = colOffset;
+            this.TileSet = new Queue<KeyValuePair<int, int>>();
+            _syncLock = new object();
+            _event = new AutoResetEvent(false);
+            _completeFlag = parent.Config.ThreadCount;
+            _raiseEvents = new Queue<EventPassing>();
+            _scale = scale;
+            _group = group;
+            _parent = parent;
+            _mapDefinition = mapdef;
+            _invoker = invoker;
+            _randomize = randomize;
+            _rows = rows;
+            _cols = cols;
+            _rowOffset = rowOffset;
+            _colOffset = colOffset;
         }
 
         public void RunAndWait()
         {
-            ThreadPool.QueueUserWorkItem(
-                new WaitCallback(QueueFiller));
-
-            for (int i = 0; i < Parent.Config.ThreadCount; i++)
+            ThreadPool.QueueUserWorkItem(QueueFiller);
+            for (int i = 0; i < _parent.Config.ThreadCount; i++)
             {
-                ThreadPool.QueueUserWorkItem(
-                    new WaitCallback(ThreadRender));
+                ThreadPool.QueueUserWorkItem(ThreadRender);
             }
 
             bool completed = false;
@@ -110,9 +107,11 @@
                 EventPassing eventToRaise = null;
                 while (true)
                 {
-                    lock (SyncLock)
-                        if (RaiseEvents.Count > 0)
-                            eventToRaise = RaiseEvents.Dequeue();
+                    lock (_syncLock)
+                    {
+                        if (_raiseEvents.Count > 0)
+                            eventToRaise = _raiseEvents.Dequeue();
+                    }
 
                     if (eventToRaise == null)
                     {
@@ -124,31 +123,31 @@
                         switch (eventToRaise.Type)
                         {
                             case EventPassing.EventType.Begin:
-                                Parent.InvokeBeginRendering(
-                                    Invoker,
-                                    Group,
-                                    Scale,
+                                _parent.InvokeBeginRendering(
+                                    _invoker,
+                                    _group,
+                                    _scale,
                                     eventToRaise.Row,
                                     eventToRaise.Col);
                                 break;
 
                             case EventPassing.EventType.Finish:
-                                Parent.InvokeFinishRendering(
-                                    Invoker,
-                                    Group,
-                                    Scale,
+                                _parent.InvokeFinishRendering(
+                                    _invoker,
+                                    _group,
+                                    _scale,
                                     eventToRaise.Row,
                                     eventToRaise.Col);
                                 break;
 
                             case EventPassing.EventType.Error:
-                                eventToRaise.Result = Parent.InvokeError(
-                                    Invoker,
-                                    Group,
-                                    Scale,
+                                eventToRaise.Result = _parent.InvokeError(
+                                    _invoker,
+                                    _group,
+                                    _scale,
                                     eventToRaise.Row,
                                     eventToRaise.Col,
-                                    ref eventToRaise.Exception);
+                                    eventToRaise.Exception);
                                 break;
 
                             default:
@@ -160,12 +159,14 @@
                     }
                 }
 
-                lock (SyncLock)
-                    if (CompleteFlag == 0 && RaiseEvents.Count == 0)
+                lock (_syncLock)
+                {
+                    if (_completeFlag == 0 && _raiseEvents.Count == 0)
                         completed = true;
+                }
 
                 if (!completed)
-                    Event.WaitOne(5 * 1000, true);
+                    _event.WaitOne(5 * 1000, true);
             }
         }
 
@@ -177,16 +178,20 @@
         {
             try
             {
-                if (Randomize)
+                if (_randomize)
                 {
                     Random ra = new Random();
                     List<int> rows = new List<int>();
-                    int[] cols_full = new int[Cols];
-                    for (int i = 0; i < Rows; i++)
+                    int[] cols_full = new int[_cols];
+                    for (int i = 0; i < _rows; i++)
+                    {
                         rows.Add(i);
+                    }
 
-                    for (int i = 0; i < Cols; i++)
+                    for (int i = 0; i < _cols; i++)
+                    {
                         cols_full[i] = i;
+                    }
 
                     //TODO: This is not really random, because we select
                     //a row, and then random columns
@@ -208,22 +213,28 @@
                             int c = cols[ci];
                             cols.RemoveAt(ci);
 
-                            AddPairToQueue(r + RowOffset, c + ColOffset);
+                            AddPairToQueue(r + _rowOffset, c + _colOffset);
                         }
                     }
                 }
                 else
                 {
                     //Non-random is straightforward
-                    for (int r = 0; r < Rows; r++)
-                        for (int c = 0; c < Cols; c++)
-                            AddPairToQueue(r + RowOffset, c + ColOffset);
+                    for (int r = 0; r < _rows; r++)
+                    {
+                        for (int c = 0; c < _cols; c++)
+                        {
+                            AddPairToQueue(r + _rowOffset, c + _colOffset);
+                        }
+                    }
                 }
             }
             finally
             {
-                lock (SyncLock)
-                    FillerComplete = true;
+                lock (_syncLock)
+                {
+                    _fillerComplete = true;
+                }
             }
         }
 
@@ -237,12 +248,14 @@
             bool added = false;
             while (!added)
             {
-                lock (SyncLock)
+                lock (_syncLock)
+                {
                     if (TileSet.Count < 500) //Keep at most 500 items in queue
                     {
                         TileSet.Enqueue(new KeyValuePair<int, int>(r, c));
                         added = true;
                     }
+                }
 
                 if (!added) //Prevent CPU spinning
                     Thread.Sleep(500);
@@ -258,37 +271,37 @@
             try
             {
                 //Create a copy of the connection for local usage
-                IServerConnection con = Parent.Connection.Clone();
+                IServerConnection con = _parent.Connection.Clone();
                 var tileSvc = (ITileService)con.GetService((int)ServiceType.Tile);
                 AutoResetEvent ev = new AutoResetEvent(false);
 
-                while (!Parent.Cancel)
+                while (!_parent.Cancel)
                 {
                     KeyValuePair<int, int>? round = null;
 
-                    lock (SyncLock)
+                    lock (_syncLock)
                     {
-                        if (TileSet.Count == 0 && FillerComplete)
+                        if (TileSet.Count == 0 && _fillerComplete)
                             return; //No more data
 
                         if (TileSet.Count > 0)
                             round = TileSet.Dequeue();
                     }
 
-                    if (Parent.Cancel)
+                    if (_parent.Cancel)
                         return;
 
                     if (round == null) //No data, but producer is still running
                         Thread.Sleep(500);
                     else
-                        RenderTile(ev, tileSvc, round.Value.Key, round.Value.Value, Scale, Group);
+                        RenderTile(ev, tileSvc, round.Value.Key, round.Value.Value, _scale, _group);
                 }
             }
             catch { }
             finally
             {
-                CompleteFlag--;
-                Event.Set();
+                _completeFlag--;
+                _event.Set();
             }
         }
 
@@ -304,28 +317,30 @@
         private void RenderTile(EventWaitHandle ev, ITileService tileSvc, long row, long col, int scaleindex, string group)
         {
             ev.Reset();
-            lock (SyncLock)
+            lock (_syncLock)
             {
-                RaiseEvents.Enqueue(new EventPassing(
+                _raiseEvents.Enqueue(new EventPassing(
                     EventPassing.EventType.Begin,
                      (int)row, (int)col, null,
                      ev
                     ));
-                Event.Set();
+                _event.Set();
             }
             ev.WaitOne(Timeout.Infinite, true);
 
-            int c = Parent.Config.RetryCount;
+            int c = _parent.Config.RetryCount;
             while (c > 0)
             {
                 c--;
                 try
                 {
-                    if (!Parent.Cancel)
-                        if (Parent.Config.RenderMethod == null)
-                            tileSvc.GetTile(MapDefinition, group, (int)col, (int)row, scaleindex, "PNG").Dispose(); //NOXLATE
+                    if (!_parent.Cancel)
+                    {
+                        if (_parent.Config.RenderMethod == null)
+                            tileSvc.GetTile(_mapDefinition, group, (int)col, (int)row, scaleindex, "PNG").Dispose(); //NOXLATE
                         else
-                            Parent.Config.RenderMethod(MapDefinition, group, (int)col, (int)row, scaleindex);
+                            _parent.Config.RenderMethod(_mapDefinition, group, (int)col, (int)row, scaleindex);
+                    }
 
                     break;
                 }
@@ -341,10 +356,10 @@
                                 ev
                                 );
 
-                        lock (SyncLock)
+                        lock (_syncLock)
                         {
-                            RaiseEvents.Enqueue(evobj);
-                            Event.Set();
+                            _raiseEvents.Enqueue(evobj);
+                            _event.Set();
                         }
 
                         ev.WaitOne(Timeout.Infinite, true);
@@ -361,14 +376,14 @@
             }
 
             ev.Reset();
-            lock (SyncLock)
+            lock (_syncLock)
             {
-                RaiseEvents.Enqueue(new EventPassing(
+                _raiseEvents.Enqueue(new EventPassing(
                     EventPassing.EventType.Finish,
                     (int)row, (int)col, null,
                     ev
                 ));
-                Event.Set();
+                _event.Set();
             }
             ev.WaitOne(Timeout.Infinite, true);
         }



More information about the mapguide-commits mailing list