Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[VB.NET] Significato di questo errore

9 views
Skip to first unread message

alverman

unread,
Dec 14, 2009, 11:15:13 AM12/14/09
to
Ho una form con una label
Quando lancio la connessione mi da un'errore all'assegnazione del
testo della label:

System.InvalidOperationException was unhandled
Message=Cross-thread operation not valid: Control 'lblMessage'
accessed from a thread other than the thread it was created on.

Perchᅵ ?

Questo ᅵ il codice:

Private Sub StartListen()
intPort = Integer.Parse(txtPort.Text)
myTcpListener = New TcpListener(Net.IPAddress.Any, intPort)

Dim blnConection As Boolean = False

Try
myTcpListener.Start()
lblMessage.Text = "Waiting..."
....


Grazie, Alverman

alverman

unread,
Dec 15, 2009, 4:39:44 AM12/15/09
to
Ok !!!
Sono riuscito a capire che per risolvere devo usare i delegate :)

Ma ora che ho risolto ho un'altro errore.
Dovendo modificare la stessa textbox da un'altra sub ho aggiunto la
stessa riga ma mi esce un'altro errore.

ChangeControlText(txtMessage, "From client - " + clNo + " : " +
dataFromClient)

A designtime di sottolinea ChangeControlText con l'errore
Error2 Reference to a non-shared member requires an object reference.

Ho giᅵ cercato in lungo e in largo ma non riesco a risolverlo

Mi date una mano per favore.

Grazie, Alverman

0 new messages