CryoEnix Posted May 7, 2006 Posted May 7, 2006 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. 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 [/Code] 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? Quote Chaos is merely logic beyond human comprehension
Administrators PlausiblyDamp Posted May 7, 2006 Administrators Posted May 7, 2006 System.Threading.Thread.Sleep(200) should do the trick Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CryoEnix Posted May 7, 2006 Author Posted May 7, 2006 System.Threading.Thread.Sleep(200) should do the trick Cheers Damp, I'll give it a try right away! Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.