private void DoPaint() { if (_rendering) return; _rendering = true; var buffer = new Bitmap(800, 800); var g = myBuffer.Graphics; //ThreadPool.QueueUserWorkItem(x => // { // var gg = CreateGraphics(); // gg.FillRectangle(new SolidBrush(Color.DarkKhaki), new Rectangle(0, 0, 800, 800)); // }); //RenderBuffer = new Bitmap(800,800); //GraphicsDevice = Graphics.FromImage(RenderBuffer); g.FillRectangle(new SolidBrush(Color.DarkKhaki), new Rectangle(0, 0, 800, 800)); HqRenderer = new HeadQuaterRenderer(buffer, g); BarrackRenderer = new BarrackRenderer(buffer, g); InfanteryRenderer = new InfanteryRenderer(buffer, g); HarvesterRenderer = new HarvesterRenderer(buffer, g); var components = GetComponents(); foreach (var component in components) { var aiColor = GetAiColor(component.OwnerId); if (component is HeadQuater) { HqRenderer.Render(component as HeadQuater, aiColor); } if (component is Barrack) { BarrackRenderer.Render(component as Barrack, aiColor); } if (component is Infantery) { if (_renderWayPointPaths) { RenderWayPointPath(component); } InfanteryRenderer.Render(component as Infantery, aiColor); } if (component is Harvester) { HarvesterRenderer.Render(component as Harvester, aiColor); } } //g = CreateGraphics(); //g.DrawImage(buffer, new Rectangle(0, 0, Width, Height)); myBuffer.Render(); _rendering = false; }