🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #351

[vb.net]Thread e RaiseEvent

#351
From: noizn
Date: Wed, 20 Sep 2006 01:51
60 lines
2603 bytes
Allora sto cercando di sviluppare un'applicazione che debba gestire un
internet point.
Quindi un server e qualche client. Seguendo guide qua e la sono riuscito a
creare un porta apertra sull'applicazione server, e a farla eseguire come un
thread separato.

Public Class Form1


    Public WithEvents t1 As TcpServer
    Public WithEvents o As New TcpServer
.
.
.

Private Sub Form1_Load....
Dim t1 As New System.Threading.Thread(AddressOf o.main)
t1.Start()
End Sub

Il Problema sta nel fatto che quando all'interno della classe che mi sono
creato scateno l'evento tcpin, non viene eseguito.


Questo dovrebbe gestirmi l'evento nel form

Public Sub SckRX(ByVal data As String) Handles t1.tcpin
Label5.Text = data
End Sub

Questo � il sunto della mia classe

Public Class TcpServer
    'Evento che indica la ricezione di un dato
    Friend Event tcpin(ByVal str As String)
    'Se false porta all'autodistruzione
    Public vita As Boolean
.
.
.
    Public Sub main()
        Dim serv As TcpListener
        serv = Nothing
        vita = True
.
.
.
                While i > 0
                    ' Translate data bytes to a ASCII string.
                    data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
                    RaiseEvent tcpin(data.ToString)
                    Debug.Write(data.ToString)
                    i = stream.Read(bytes, 0, bytes.Length)
                End While


ovviamente manca un po di codice ma nulla di fondamentale credo. comunque
sia quando do il RaiseEvent tcpin(data.ToString) non succede nulla.
Ovviamente nel debug compagliono i miei dati ma la label non viene
aggiornata. Chi mi sa aiutare? 
Technical Details
Message-ID: <45109ea7$0$1010$5fc30a8@news.tiscali.it>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!news.mailgate.org!draco.tiscalinet.it!news-f1.tiscali.it!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f94ee,fd5e972c8d0313d5,start
X-Google-Attributes: gidf94ee,public
X-Google-Language: ITALIAN,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!news.mailgate.org!draco.tiscalinet.it!news-f1.tiscali.it!not-for-mail
Reply-To: "noizn" <noizn@tiscali.it>
From: "noizn" <noizn@tiscali.it>
Newsgroups: free.it.visual-basic
Subject: [vb.net]Thread e RaiseEvent
Date: Wed, 20 Sep 2006 03:51:46 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962
Lines: 62
Message-ID: <45109ea7$0$1010$5fc30a8@news.tiscali.it>
Organization: Tiscali SpA
NNTP-Posting-Host: 84.220.49.106
X-Trace: 1158717095 news.tiscali.it 1010 84.220.49.106:1495
X-Complaints-To: abuse@tiscali.it