Add try catch to startup manager codes

This commit is contained in:
Jaex 2017-10-08 11:04:26 +03:00
parent 89820bad63
commit 295749d711

View file

@ -256,15 +256,23 @@ private void UpdateStartWithWindows()
cbStartWithWindows.Text = Resources.ApplicationSettingsForm_cbStartWithWindows_Text;
cbStartWithWindows.Enabled = false;
StartupTaskState state = StartupManagerFactory.StartupManager.State;
cbStartWithWindows.Checked = state == StartupTaskState.Enabled;
if (state == StartupTaskState.DisabledByUser)
try
{
cbStartWithWindows.Text = Resources.ApplicationSettingsForm_cbStartWithWindows_DisabledByUser_Text;
StartupTaskState state = StartupManagerFactory.StartupManager.State;
cbStartWithWindows.Checked = state == StartupTaskState.Enabled;
if (state == StartupTaskState.DisabledByUser)
{
cbStartWithWindows.Text = Resources.ApplicationSettingsForm_cbStartWithWindows_DisabledByUser_Text;
}
else
{
cbStartWithWindows.Enabled = true;
}
}
else
catch (Exception e)
{
cbStartWithWindows.Enabled = true;
e.ShowError();
}
ready = true;
@ -397,8 +405,15 @@ private void cbStartWithWindows_CheckedChanged(object sender, EventArgs e)
{
if (ready)
{
StartupManagerFactory.StartupManager.State = cbStartWithWindows.Checked ? StartupTaskState.Enabled : StartupTaskState.Disabled;
UpdateStartWithWindows();
try
{
StartupManagerFactory.StartupManager.State = cbStartWithWindows.Checked ? StartupTaskState.Enabled : StartupTaskState.Disabled;
UpdateStartWithWindows();
}
catch (Exception ex)
{
ex.ShowError();
}
}
}