Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching Between System Power Saving Mode in UWP app ,makes the app non-responded for a while #1415

Open
Prem-Kumar-Shanmugam opened this issue Jun 28, 2024 · 0 comments
Labels

Comments

@Prem-Kumar-Shanmugam
Copy link

Prem-Kumar-Shanmugam commented Jun 28, 2024

My UWP app was not responding for sometime, when switching between power Saving mode(windows settings) while App was running. To Reproduce the issue ,
1. Run the app
2. Open Windows System Battery Settings -> Enable/Disable Power Saving Mode
3. Now try to bring our UWP app window to Foreground(front) -> It takes sometime to bring the app to foreground state from
background state.

My XAML Code :
<Canvas x:Name="MyCanvas" Background="Aqua"/>

My C# Code
RelativePanel buttonsPanel = new RelativePanel(); Button previousButton = null; for (int i = 0; i < 500; i++) { Button currentButton = new Button(); currentButton.Width = 10; currentButton.Height = 10; currentButton.Background = new SolidColorBrush(Colors.Blue); currentButton.BorderBrush = new SolidColorBrush(Colors.Red); buttonsPanel.Children.Add(currentButton); if (previousButton != null) { RelativePanel.SetBelow(currentButton, previousButton); } previousButton = currentButton; } MyCanvas.Children.Add(buttonsPanel);

I just add 500 buttons inside relative panel and aligned the each button below the above one using RelativePanel.SetBelow(currentButton, previousButton).

If I remove the RelativePanel.SetBelow() line, the app respond properly as expected. But I want to align the children inside RelativePanel relatively. On the other hand, If I move the above c# code completely to XAML, it works fine in that case also. Example ...

XAML :

<Canvas x:Name="MyCanvas" Background="Aqua"> <RelativePanel> <Border Name="b0" Width="10" Height="10" Background="Blue" BorderBrush="Red" /> <Button Name="b1" Width="10" Height="10" Background="Blue" BorderBrush="Red" RelativePanel.Below="b0" /> <Button Name="b2" Width="10" Height="10" Background="Blue" BorderBrush="Red" RelativePanel.Below="b1" /> <Button Name="b3" Width="10" Height="10" Background="Blue" BorderBrush="Red" RelativePanel.Below="b2" /> <Button Name="b4" Width="10" Height="10" Background="Blue" BorderBrush="Red" RelativePanel.Below="b3" /> <Button Name="b5" Width="10" Height="10" Background="Blue" BorderBrush="Red" RelativePanel.Below="b4" /> . . . . <Button Name="b500" Width="10" Height="10" Background="Blue" BorderBrush="Red" RelativePanel.Below="b499" /> </RelativePanel> </Canvas>

Atleast we showld have 500 Buttons inside the relative panel to reproduce the issue. I don't know why this is happening, when i write the code completely in XAML , it works fine only. But if I add the buttons in C# and aligned relatively, the app won't respond properly while switching between power saving mode. I think the issue is with setting the Relativepanel.SetBelow() line. My Sample Project link https://drive.google.com/drive/folders/1tn8-m_SJYsOvZ8atEGASmXrrP-z2QfU8?usp=sharing

Tasks

Preview Give feedback
No tasks being tracked yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant