Reputation: 33
I am having a problem with my code.
Says the value is set, but not used...
I get the nice green line under bool _isInBackgroundMode = false;
What am I not getting here?
namespace MyApp
{
using Views;
using Windows.UI;
using Windows.UI.ViewManagement;
sealed partial class App : Application
{
bool _isInBackgroundMode = false;
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.EnteredBackground += App_EnteredBackground;
this.LeavingBackground += App_LeavingBackground;
}
private void App_EnteredBackground(object sender, EnteredBackgroundEventArgs e)
{
_isInBackgroundMode = true;
}
private void App_LeavingBackground(object sender, LeavingBackgroundEventArgs e)
{
_isInBackgroundMode = false;
}
Upvotes: 0
Views: 106
Reputation: 6749
This is because you don't have any code reading that value. As of now; or at least what you've shown; you are only setting the value and no where is it actually used (read from).
Once you write code that says something like
if (_isInBackgroundMode)
doSomething();
Then the green line will go away.
Upvotes: 1