How to make drawing control objects faster in a C form#

In a form, in desktop c#, constant moves of certain controls occur. In this case I am using objects of type PictureBox, but their rendering is very time consuming. Is it recommended to use another control object for this? And how do you make the movement of certain control done asynchronously?

Author: Maniero, 2014-09-10

1 answers

You can put any logic you want asynchronously into an object of Class System.Windows.Forms.Form. But the screen update is done in an internal method that is synchronous. If you want to animate movement of controls in a form application, you are doomed to have to deal with flicker and with your thread locked while all controls are redesigned. There's no escape.

If you really need these animations, you have three options:

  • Develop as it was in the time of Abraham : make the form with pure C++, without .NET, implementing your own drawing process on the canvas (probably unfeasible, right?);

  • To stay in the .NET world, you can also use XNA. but XNA is more suitable for gaming. Seems to me to be what you're doing (I've never seen productivity app, spreadsheet or word processor type, with animated controls);

  • Use Windows Presentation Foundation . is a .NET subframework that was created, among other things, for needs like yours. Get the tip ;)

 4
Author: Garoto de Programa, 2014-09-10 17:32:51