0

Hey I want to draw 3 shapes for example 3 squares in 3 different "private new async void". To achieve this I'm using:

using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
                        {
                          g.DrawRectangle(Pens.Red, SizeX, SizeY, X, Y);
                        }

The isssue is that it starts flickering and also slows down the program (feels like it is lagging). I want to keep the square refreshing like every 1ms since it is moving.

I already set DoubleBuffering to true but each square flickers on its on successively really fast.

Is there another method to fix this than Double Buffering or am I doing smth wrong.

Yuuta
  • 43
  • 6
  • https://stackoverflow.com/questions/2608909/c-sharp-graphics-flickering – Mitch Wheat May 04 '20 at 03:20
  • 2
    What is a `private new async void`? Do you know what `Graphics.FromHwnd(IntPtr.Zero)` is doing? You need to describe what are trying to paint on, possibly what and when (yes, rectangles, but to what end?). You cannot paint anything *every 1ms*, you can paint something at the maximum speed possible invalidating a control in its Paint event. It has consequences, though. If you're using a Timer, verify its maximum resolution. – Jimi May 04 '20 at 05:04
  • @MitchWheat as I stated in my Question Double Buffering is set to true i read that article before. – Yuuta May 04 '20 at 14:17
  • The accepted answer doesn't just mention double buffering – Mitch Wheat May 04 '20 at 23:31

0 Answers0