Fix bug related to collection modification during Application.Restart() on ChangePassword.

This commit is contained in:
Junior 2023-10-05 23:36:56 -03:00
parent 46b2b6f15d
commit d5ec712d0f
3 changed files with 26 additions and 15 deletions

View file

@ -63,7 +63,9 @@ namespace RHLauncher
private void HandleSendEmailResponse(string response)
{
switch (response)
Invoke((MethodInvoker)(() =>
{
switch (response)
{
case "EmailSent":
SendEmailButton.Enabled = false;
@ -102,22 +104,25 @@ namespace RHLauncher
default:
MsgBoxForm.Show("Error:" + response, LocalizedStrings.Error);
break;
}
}
}));
}
private void ResendTimer_Tick(object? sender, EventArgs e)
{
// Decrement the secondsLeft variable and update the button text
secondsLeft--;
TimerLabel.Text = $"({secondsLeft})";
// If the timer has finished counting down, stop the timer and enable the ResendEmailButton
if (secondsLeft == 0)
Invoke((MethodInvoker)(() =>
{
resendTimer.Stop();
SendEmailButton.Enabled = true;
TimerLabel.Text = "";
}
TimerLabel.Text = $"({secondsLeft})";
if (secondsLeft == 0)
{
resendTimer.Stop();
SendEmailButton.Enabled = true;
TimerLabel.Text = "";
}
}));
}
private async Task<string> VerifyCodeSendRequestAsync()
@ -155,11 +160,12 @@ namespace RHLauncher
registryHandler = new RegistryHandler();
registryHandler.ClearPassword();
Invoke((MethodInvoker)(() => Close()));
Application.Restart();
}
else
{
Close();
Invoke((MethodInvoker)(() => Close()));
}
}

View file

@ -460,19 +460,24 @@ namespace RHLauncher
public void Logout()
{
LoginForm? loginForm = Application.OpenForms.OfType<LoginForm>().FirstOrDefault();
LoginForm loginForm = Application.OpenForms.OfType<LoginForm>().FirstOrDefault();
if (loginForm != null)
{
// Close the current form before restarting
Close();
// Restart the application
Application.Restart();
}
else
{
LoginForm newLoginForm = new();
LoginForm newLoginForm = new LoginForm();
newLoginForm.Show();
Close();
}
}
private async void UpdateCheckButton_Click(object sender, EventArgs e)
{
HidePanels();

View file

@ -19,8 +19,8 @@
<AssemblyName>Launcher</AssemblyName>
<Description>Rusty Hearts Launcher</Description>
<PlatformTarget>x86</PlatformTarget>
<AssemblyVersion>1.0.2</AssemblyVersion>
<FileVersion>1.0.2</FileVersion>
<AssemblyVersion>1.0.3</AssemblyVersion>
<FileVersion>1.0.3</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">