C
C#6mo ago
Mekiaqu

Visual Studio C# WinForms, a question for better performance.

Hello! I am making a rocket ground station application. There is a serial port connection which gives me rocket's data to display it on screen. I am displaying this variables properly but there is 2 designs in the screenshot at the bottom. Which shows rocket's degree with ground and speed of it. Serial port receiving data in every 100 miliseconds and my application rotating these pictures like a realistic gauge. But when data is coming too fast, variables are displaying wrong a lot because rotating these photos making my application a bit busy. What can I do for this? I don't know how to rotate them in an async way. I am using Guna2 NuGet package for design.
No description
21 Replies
Jimmacle
Jimmacle6mo ago
realistic as in it takes time for the needle to move?
Mekiaqu
MekiaquOP6mo ago
as you see in the video, after finishing displaying gauges, application just getting fast
Mekiaqu
MekiaquOP6mo ago
gauge showing the value directly there is no animation like if 200m/s means 90 degree app just rotation the image to 90 degree to show it is 200m/s
Buddy
Buddy6mo ago
Unfortunately WinForms isn't known for its performance It's terrible if you want transparency and/or performance
Jimmacle
Jimmacle6mo ago
this sounds like a throttling thing, you'd want to start skipping updates if the UI is falling behind
Buddy
Buddy6mo ago
I would recommend WPF as it's significantly better regarding performance. And yes, as Jimmacle mentioned. It definitely sounds like throttling Possible to poll it instead? So the UI reports when it needs an update, and not the other way around.
Mekiaqu
MekiaquOP6mo ago
does wpf have lot of difference with winforms? about coding designing and Packages sorry for my untechnical english but what do you mean Can you describe a bit more
Buddy
Buddy6mo ago
yes WPF is a xaml based ui framework You should never use the designer $rulesofwpf
MODiX
MODiX6mo ago
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Mekiaqu
MekiaquOP6mo ago
I think I am a bit late to make my project in wpf lol and also I don't have much idea about wpf so creating a spesific app like rocket management system might be a bad idea
Buddy
Buddy6mo ago
WPF has been in development for a loong time, it is stable enough. Winforms is ancient technology.
Mekiaqu
MekiaquOP6mo ago
can you describe a bit more please
Jimmacle
Jimmacle6mo ago
basically, make the UI ignore new data if it's still updating from the old data so it doesn't slow down
Mekiaqu
MekiaquOP6mo ago
yeah ofc but I don't know xml or other things about wpf so I see but that means it will be unsmoothed display with correct varibles I have to choose in the end
Buddy
Buddy6mo ago
Not many apps updates data that frequently
Mekiaqu
MekiaquOP6mo ago
Can I make my app use more ram ?
Buddy
Buddy6mo ago
No, this isnt Java. .NET manages the RAM automatically, no need to dedicate X amount of RAM
Mekiaqu
MekiaquOP6mo ago
I see rotating picturebox with async method maybe? would this work I just need only a bit better performance
Jimmacle
Jimmacle6mo ago
if the underlying operations aren't async, making the method async won't help async is most useful with IO where the CPU doesn't have to do any work while waiting for the operation to complete
Mekiaqu
MekiaquOP6mo ago
So there is no exit except increasing update interval I think I should to learn wpf as soon as possible I mean you saying wpf is one the best desktop app developing way right?
Jimmacle
Jimmacle6mo ago
WPF is better than winforms for more complex apps
Want results from more Discord servers?
Add your server