Здравствуйте!
Подскажите пожалуйста, есть
таймер
mVarTimer = New Threading.Timer(AddressOf WorkTime, Me, 0, 1000)
вызывает
Public Sub WorkTime(ByVal StateObj As Object)
Dim State As Tim = CType(StateObj, Tim)
Dim tmpVarSec As Integer
System.Threading.Interlocked.Increment(State.CurrentTime)
tmpVarSec = System.Threading.Interlocked.Read(State.CurrentTime)
If tmpVarSec > State.mvarTimeWorkMax Then
State.mVarTimer.Dispose()
System.Threading.Interlocked.Exchange(State.TimerWork, 0)
RaiseEvent TimerIncrementSecunda(tmpVarSec, True)
Else
RaiseEvent TimerIncrementSecunda(tmpVarSec, False)
End If
End Sub
главная программа
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler My.Application.tmpV.TimerIncrementSecunda, AddressOf TimerEvent
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
My.Application.tmpV.startTimer()
End Sub
Private Sub TimerEvent(ByVal curtime As Integer, ByVal stopTimer As Boolean)
Label1.Text = curtime '-здесь ошибка.обращение к данным созданным в другом потоке
End Sub
Каким образом мне сделать так что поток вызываемый таймером мог видеть данные потока главной формы в частности
my.application.[......]
???