Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm new,very new to C# (you can even say ultimately new to C#)
i'm writing a program and stumbled upon performance problem.

I have two form,my problem is the 2nd form.It's contain about 960 controls (button exactly) and when it's called it took more than 5 minutes to show up.

and after seraches on the internet i found that it's wrong to put a massive amount of control in one window is wrong.

so if divide it,say to four diffrent form and should called separately,will this resolve my problem ? or can i make the Form loader work multi-threaded ?

Thankyou
Posted
Comments
[no name] 20-Apr-14 12:39pm    
Without knowing more, I would say that your idea would probably not solve any issue. It would appear to me that you have a fundamental architectural issue/misconception that has nothing to do with any performance.

You cannot thread this. All controls and their creation must be on the UI (sometimes referred to as the "startup") thread.

You can create controls on different threads and they may even appear to work, most of the time. But you will get the weirdest, unreproducable bugs when using the application if you do.

It is simply not a good practice to have 960 buttons not only on 1 form, but in any number of forms on screen at the same time! How is the user going to navigate through this massive pile of controls to find the one they are trying to click on??

This sounds like you're trying to use buttons as some representation of an image on a form, perhaps a game, and you don't know how else to do something other than use a button.

Oh, and a separate form does NOT mean a separate thread. All forms will be on the same thread of execution.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-Apr-14 12:59pm    
5ed.
—SA
Tommy Aria Pradana 22-Apr-14 11:12am    
Yes,i intend to separate the buttons to diffrent forms,so when a spesific form were called it would only show the form and the buttons that i've put on that form.
Will this help ?
Dave Kreskowiak 22-Apr-14 11:47am    
I ahve no idea. I have no idea what this app is or what you're doing with all the buttons. I have no idea how many buttons you're putting on there broken out forms.
Tommy Aria Pradana 23-Apr-14 2:45am    
Okay then,well how about,how much is the max amount of control that normally a form can handle ?
Dave Kreskowiak 23-Apr-14 7:49am    
There is no answer to that question. It's whatever is practical.

If you're thinking about that many buttons, you've got a serious user interface design problem. You STILL haven't said anything about what all there buttons are for and what this app is going to be doing.
Answering the specific question in the title, thread and form are two different things. C# is not a real compiler in the original sense. C# "compiles" to an intermediate form which is not compiled to "native?" code until runtime. The performance problem probably comes from the JIT compile at runtime. A simpler form will probably compile and display faster. There may be other issues.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900