PDA

View Full Version : [VB.NET] Evento in thread in background


Capello82
23-04-2008, 16:49
Salve a tutti. Mi chiedevo se fosse possibile mettere il seguente evento in un thread in background, in modo che l'applicazione sia "responsive":

Private Sub PinChange(ByVal sender As Object, ByVal e As System.IO.Ports.SerialPinChangedEventArgs) Handles serialPort.PinChanged
Me.Invoke(New PinChangeDelegate(AddressOf updatePin), New Object() {})
End Sub

Public Delegate Sub PinChangeDelegate()
Public Sub updatePin()
Application.DoEvents()
If IO.Ports.SerialPinChange.CtsChanged And send_complete = False Then
Threading.Thread.Sleep(100)
InviaDati()
End If
End Sub

MarcoGG
24-04-2008, 13:27
Sul multithreading in VB.NET sono anch'io in fase di "sperimentazione", ;) .
In generale devi impostare la proprietà del Thread desiderato
.IsBackground = True ...

Capello82
28-04-2008, 10:02
Si.. ma non riesco ad impostare il resto :S