I'm using timer
as follows:
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = 1000;
aTimer.Enabled = true;
In the OnTimedEvent
method I do the following:
var auditoria = auditoriaBll.Retorna_Auditoria();
foreach (var item in auditoria)
{
//menu e sub menu (categorias)
if (item.Tabela.Equals("menus"))
{
txtRelatorio.Text = andamento;
}
}
The following error occurs:
Invalid thread operation: control 'txtRelatorio' accessed from a thread that is not the one it was created in.