public void LaunchSelectedBoatDataRefreshTask() { StopSelectedBoatDataRefreshTask(); if (SelectedBoatNumber != null) { SelectedBoatCancellationTokenSource = new CancellationTokenSource(); Tasks.RefreshSelectedBoat(SelectedBoatCancellationTokenSource.Token); NmeaServer.Start(); TimeSpan t = TimeSpan.FromMilliseconds(Conf.REQUEST_RATE); string humanReadableRate = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("RequestRateInformation")}{humanReadableRate}"))); MessageHub.PublishAsync(new BoatDataServiceStatusChanged(Global.Instance, true)); } }
private void buttonStartServer_Click(object sender, EventArgs e) { if (nmeaServer == null || !nmeaServer.Started) { nmeaServer = new NMEAServer(ref boatData, Convert.ToInt32(numericUpDownPort.Value), Convert.ToInt32(numericUpDownRate.Value)); nmeaServer.Start(); buttonStartServer.Text = "Stop server"; } else { nmeaServer.Stop(); buttonStartServer.Text = "Start server"; } numericUpDownPort.Enabled = !nmeaServer.Started; numericUpDownRate.Enabled = !nmeaServer.Started; }