Skip to content

Commit

Permalink
rtk/gps: use beginInvoke() inside async functions
Browse files Browse the repository at this point in the history
Use `beginInvoke()` inside asynchronous functions to update the UI from
the UI thread.
  • Loading branch information
flyingthingsintothings committed Apr 11, 2024
1 parent a6775b7 commit 32a5837
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions GCSViews/ConfigurationView/ConfigSerialInjectGPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ void saveBasePosList()

public async void BUT_connect_Click(object sender, EventArgs e)
{
if (!InvokeRequired)
{
log.Info("We're running on the UI thread");
}
threadrun = false;
if (comPort.IsOpen)
{
Expand Down Expand Up @@ -501,10 +497,6 @@ public async Task DoConnect()
bytes = 0;
invalidateRTCMStatus();
panel1.Controls.Clear();
if (!InvokeRequired)
{
log.Info("We're running on the UI thread");
}
}

/// <summary>
Expand Down Expand Up @@ -538,7 +530,7 @@ private async Task ConfigureSeptentrioReceiver()
CustomMessageBox.Show("Septentrio fixed base position is invalid.");
}

CMB_baudrate.Text = $"{Utilities.Septentrio.DefaultBaudrate}";
this.BeginInvokeIfRequired(new Action(() => CMB_baudrate.Text = $"{Utilities.Septentrio.DefaultBaudrate}"));
}

void invalidateRTCMStatus()
Expand Down Expand Up @@ -1415,7 +1407,7 @@ private void comboBoxConfigType_SelectedIndexChanged(object sender, EventArgs e)
// Use Click event because we aren't interested in code changes to the value, only user changes
private async void chk_septentriofixedposition_Click(object sender, EventArgs e)
{
button_septentriosetposition.Enabled = chk_septentriofixedposition.Checked;
this.BeginInvokeIfRequired(new Action(() => button_septentriosetposition.Enabled = chk_septentriofixedposition.Checked));

try
{
Expand Down

0 comments on commit 32a5837

Please sign in to comment.