У меня есть таймер, который при запуске должен установить ярлык как видимый. Когда я вызываю метод, который делает это, он дает следующее исключение:пытается установить метку из метода, вызванного таймером, в той же форме, что и ошибка получения
Неверное выполнение кросс-потоков: управление «Startup2» осуществляется из потока, отличного от потока, на котором он был создан.
Мой таймер:
void GpsTimerElapsed(object sender, ElapsedEventArgs e)
{
if (!ServicesConfig.MiscClasses.VerifyInternetAccess.HasInternet())
{
toolStripStatusLabel_Status.Text = "Internet not available!!";
_history.History = "GPS Readings - Internet access not available.";
HasError();
return;
}
toolStripStatusLabel_Status.Text = "Processing GPS data.";
_history.History = "GPS Readings - Timer ticked...";
_gpsTimer.Stop();
_history.History = "GPS Readings - Timer stopped...";
var process = new ProcessGpsFile();
_history.History = "GPS Readings - Timer processing Reading started...";
if (process.ProcessReading()) HasError();
_history.History = "GPS Readings - Timer processing Reading finished...";
_gpsTimer.Start();
_history.History = "GPS Readings - Timer started.";
_history.History = "--------------------------------------------------------";
toolStripStatusLabel_Status.Text = "Process GPS data complete.";
}
Мой метод с меткой:
private void HasError()
{
pictureBox_Status.Image = Properties.Resources.yellow;
label_ClickToSeeError.Visible = true;
}
Я ненавижу предположить, но это означает, что таймер работает на его собственном потоке, отдельно от формы? Как это исправить?
Еще раз спасибо!
благодарит за информацию! – ErocM