29/08/16 17:41
orma674
Ciao a tutti.
Cerco aiuto per superare l'errore in oggetto, premetto senza disattivare il controllo da codice.
Vi riporto il codice che ho scritto per testare, se qualcuno mi da una mano a renderlo funzionale.
Imports System.Threading.Thread
Public Class Form1
Dim WithEvents xx As New test
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub xx_testEvento(sender As Object, e As newEvento) Handles xx.testEvento
Me.Text = e.data
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
xx.onTest()
End Sub
End Class
Public Class newEvento
Inherits EventArgs
Public data
End Class
Public Class test
Dim eee As New newEvento
Public Delegate Sub testDelegate(ByVal sender As Object, e As newEvento)
Public Event testEvento(ByVal sender As Object, e As newEvento)
Public ff As New Threading.Thread(AddressOf onThread)
Public Sub onTest()
ff.Start()
End Sub
Sub onThread()
Do
onXXX()
Loop
End Sub
Protected Overridable Sub onXXX()
eee.data = TimeOfDay.ToString
RaiseEvent testEvento(Me, eee)
End Sub
End Class
Ringrazio tutti anticipatamente della collaborazione.
Marcello
Cerco aiuto per superare l'errore in oggetto, premetto senza disattivare il controllo da codice.
Vi riporto il codice che ho scritto per testare, se qualcuno mi da una mano a renderlo funzionale.
Imports System.Threading.Thread
Public Class Form1
Dim WithEvents xx As New test
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub xx_testEvento(sender As Object, e As newEvento) Handles xx.testEvento
Me.Text = e.data
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
xx.onTest()
End Sub
End Class
Public Class newEvento
Inherits EventArgs
Public data
End Class
Public Class test
Dim eee As New newEvento
Public Delegate Sub testDelegate(ByVal sender As Object, e As newEvento)
Public Event testEvento(ByVal sender As Object, e As newEvento)
Public ff As New Threading.Thread(AddressOf onThread)
Public Sub onTest()
ff.Start()
End Sub
Sub onThread()
Do
onXXX()
Loop
End Sub
Protected Overridable Sub onXXX()
eee.data = TimeOfDay.ToString
RaiseEvent testEvento(Me, eee)
End Sub
End Class
Ringrazio tutti anticipatamente della collaborazione.
Marcello
aaa