How to make object design control faster in a C#form

Asked

Viewed 394 times

3

In a form, in C# for desktop, there are constant movements of certain controls. In this case I am using objects of type Picturebox, however its rendering is very time consuming. Is it recommended to use another control object for this? And it has how to make the movement of certain control done asynchronously?

  • 1

    See the code generated by Visual Studio when you draw a form. It freezes the rendering before adding the components and then defrosts - only then are the controls quickly rendered and rendered imperceptible to the user. I don’t have Visual Studio here otherwise I would take a look and tell you what the command is. But you will find it easy.

1 answer

4


You can put any logic you want asynchronously into a class object 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 its thread locked while all controls are redesigned. There is no escape.

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

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

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

  • Use the Windows Presentation Foundation. It is a "subframework" of . NET that was created, among other things, for needs like yours. Here’s the tip ;)

  • But I need to do the same on a desktop form in c#

  • Then you will have to learn to live with the problems you described. Bones of the craft.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.