F
fniles
I am using VB.NET 2003 and a socket control. As I get quotes, I add the
quote to the arraylist, and I send the quotes to my clients by removing the
message from the arraylist and send it to the client using the socket.
I found that the arraylist got backed up, the queue depth will be 1000 or
bigger. I put a Thread.Sleep(1) outside the While Loop where I remove the
item from the arraylist. Shall I
1. not use Thread. Sleep
Or
2. use Thread.sleep inside the While Loop ?
Shall I use Thread.sleep(0) or Thread.sleep(1) ?
THank you.
Private Quotes As New ArrayList
Private QuotesSync As ArrayList = ArrayList.Synchronized(Quotes)
Sub NewQuote(ByVal Message As String)
QuotesSync.Add(Message)
end sub
Sub ThreadMain()
While QuotesSync.Count > 0
sPacket = QuotesSync(0)
nResult = Socket.Write(sPacket)
QuotesSync.RemoveAt(0)
'---------------------> SHALL I MOVE Thread.Sleep(1) HERE
? ---------------------------
End While
Thread.Sleep(1)
:
End Sub
quote to the arraylist, and I send the quotes to my clients by removing the
message from the arraylist and send it to the client using the socket.
I found that the arraylist got backed up, the queue depth will be 1000 or
bigger. I put a Thread.Sleep(1) outside the While Loop where I remove the
item from the arraylist. Shall I
1. not use Thread. Sleep
Or
2. use Thread.sleep inside the While Loop ?
Shall I use Thread.sleep(0) or Thread.sleep(1) ?
THank you.
Private Quotes As New ArrayList
Private QuotesSync As ArrayList = ArrayList.Synchronized(Quotes)
Sub NewQuote(ByVal Message As String)
QuotesSync.Add(Message)
end sub
Sub ThreadMain()
While QuotesSync.Count > 0
sPacket = QuotesSync(0)
nResult = Socket.Write(sPacket)
QuotesSync.RemoveAt(0)
'---------------------> SHALL I MOVE Thread.Sleep(1) HERE
? ---------------------------
End While
Thread.Sleep(1)
:
End Sub