My Timer event crashes because the events are called on a different thread

前端 未结 8 1749
再見小時候
再見小時候 2021-01-21 10:49

I get the error \"Cross-thread operation not valid: Control \'label1\' accessed from a thread other than the thread it was created on.\" when I run this code:

us         


        
8条回答
  •  既然无缘
    2021-01-21 11:23

    I am not a winform developer. But i heard something regararding Timer class which you are using. I think you might want to set these properties and check.

    T.Interval = 5000; //in Mili Seconds
    T.Enabled = true;
    

提交回复
热议问题