Annoying error

CryoEnix

Regular
Joined
Jan 11, 2003
Messages
93
Location
Wrexham, Wales
Hey all, I'm currently writing a VB.NET DLL to handle TCP sockets in the same way as the old VB6 WinSock control, to simplify it for myself. However, I've run into this error:

"Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated"

The key code is below (a snippet from the class), and I've highlighted the line that causes the error.

Code:
Public Event DataArrival(ByVal bytesTotal As Long)


Private sck As System.Net.Sockets.TcpClient
Private stream As System.Net.Sockets.NetworkStream
Private newThread As System.Threading.Thread

 Public Sub New()
        sck = New System.Net.Sockets.TcpClient()
        stream = sck.GetStream

        newThread = New System.Threading.Thread(AddressOf listenSub)
        newThread.Priority = Threading.ThreadPriority.Normal
        newThread.Start()
    End Sub

    Private Sub listenSub()
        Do
            [COLOR=Red]newThread.Sleep(200)[/COLOR]'This is the problem!
            If stream.Length <> 0 Then
                RaiseEvent DataArrival(stream.Length)
            End If
        Loop

    End Sub

Now what that line is supposed to achieve is to pause the listening loop whilst checking for data being sent to the socket to avoid CPU burn. How do I fix this error, or is there a better way to implement this loop?
 
Back
Top