Program loads resources painfully slow (visual c#)
Hi. I’ve got a problem with my program which loads resource images into buttons painfully slow (as shown on video). Have you got any ideas why this happens?
11 Replies
You need to post code to figure out why it's slow
I'm taking a guess, you're doing something heavy on the forms loaded/shown event handlers
I assume this is Winforms?
Only winforms acts in that way from experience
Also Visual C# is not a thing, C# yes. Not Visual C#.
Use modern tools not ancient tech developed in the beginning of the 2000s
Use frameworks like WPF or Avalonia if it is desktop.
They both allow you to customize the style of buttons without the use of images.
And they are significantly faster than Winforms, also more modern.
WPF is developed by Microsoft for exclusively Windows while Avalonia is an open source cross-platform UI framework for .NET, that also supports NativeAOT unlike WPF.
I will have to clean up my code, it’s over 5000 lines in one form
and the i will share it
też, is it that bad?
Over 5000 lines in one form
- sounds like pure sequential code.Winforms is awful and ancient, yes.
It looks like it's re-rendering something many many times there
or instantiating the form X times
Do u think that resource file with button images might be an issue?
its actually 3000 now, had to clean this one up
What if I wanted to try out WPF, would I have to write the entire app all over again?
Or is there some correlation between WPF and winforms?
Yes.
WPF is xaml based, winforms is not.
However if you wrote your backend separately from the UI it is possible to port it over fairly easily.
Only thing would be the UI
$rulesofwpf
Make sure you read this!
Especially this