///<summary>Flash geometry on the display.</summary>
        ///<param name="geometry"> The input IGeometry to flash.  Supported geometry types are GeometryBag, Polygon, Polyline, Point and Multipoint.</param>
        ///<param name="screenDisplay">An IScreenDisplay reference</param>
        ///<param name="delay">An integer that is the time in milliseconds to wait.</param>
        public static void FlashGeometry(IGeometry geometry, IScreenDisplay screenDisplay, int delay, int times)
        {
            if (geometry == null || screenDisplay == null)
            {
                return;
            }
            bool continueFlashing = true;

            using (ComReleaser comReleaser = new ComReleaser())
            {
                ITrackCancel cancelTracker = new CancelTrackerClass();
                comReleaser.ManageLifetime(cancelTracker);
                screenDisplay.CancelTracker = cancelTracker;
                short cacheID = screenDisplay.AddCache();
                int cacheMemDC = screenDisplay.get_CacheMemDC(cacheID);
                
                IRgbColor fillColor = new RgbColorClass();
                comReleaser.ManageLifetime(fillColor);
                fillColor.Green = 128;
                IRgbColor lineColor = new RgbColorClass();
                comReleaser.ManageLifetime(lineColor);

                screenDisplay.StartDrawing(cacheMemDC, cacheID);
                DrawGeometry(geometry, fillColor, lineColor, (IDisplay)screenDisplay, cancelTracker);
                ESRI.ArcGIS.esriSystem.tagRECT RECT = new tagRECT();
                screenDisplay.FinishDrawing();

                for (int j = 0; j < times; j++)
                {
                    if (continueFlashing == true)
                    {
                        screenDisplay.DrawCache(screenDisplay.hDC, cacheID, ref RECT, ref RECT);
                        if (delay > 0)
                        {
                            System.Threading.Thread.Sleep(delay);
                            screenDisplay.Invalidate(null, true, cacheID);
                            screenDisplay.UpdateWindow();
                            System.Threading.Thread.Sleep(delay);
                        }
                    }
                }
                //---------------------------------------------------------------------

                screenDisplay.RemoveCache(cacheID);
                cancelTracker.Reset();
            }
        }