private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { label16.Text = "Status: defining weather data for a selected city..."; label16.ForeColor = Color.Gray; string city = Convert.ToString(comboBox1.SelectedItem); Task.Run(() => { OpenWeather.OpenWeather openWeather = weather.GetOpenWeatherByCity(city); if (openWeather != null) { coordinate = new GeoCoordinate(openWeather.Coord.Lat, openWeather.Coord.Lon); openWeatherOneAPI = weather.GetWeather(coordinate); if (InvokeRequired) { Invoke(new Action(() => SetParameters())); } else { SetParameters(); } } else { label16.Text = "Status: city geodata not defined."; label16.ForeColor = Color.Red; } }); }