F
fniles
I create a thread where I pass thru a message. When I click very fast many
times (like 50 times) to create 50 threads, the message did not get pass
thru ProcessMessage.
For example: strBuffer = "#TRADE, D1410-123456, BUY, 1, ESM7, DAY, LIMIT,
1490.00, , , 0, 0, 0, 0, 0, links |52994/25/2007 10:47:17 AM !A", when I
trigger to create many threads (like 50), this message did not get to sub
ProcessMessage in clsEachMessage.
I have added Thread.Sleep(0) after the Start method of the thread.
What is the best way to do the thread so that every message get pass thru to
it ?
Is there a maximum number of thread that I can create ?
Shall I use thread pool instead of creating a new thread each time ?
Thank you very much.
Dim EachMessageThread As Threading.Thread = Nothing
Dim clsEachMessage As New EachMessage
clsEachMessage.sMessage = strBuffer
EachMessageThread = New Threading.Thread(AddressOf
clsEachMessage.ProcessMessage)
threadCount += 1
EachMessageThread.Name = "Thread " & threadCount.ToString()
EachMessageThread.Start()
Thread.Sleep(0)
Public Class EachMessage
Public sMessage As String
Public Sub ProcessMessage()
Dim swError As StreamWriter
swLog = New StreamWriter(sPath & "\log\Input.txt", True)
swLog.Write(sMessage & vbCrLf)
swLog.Close()
swLog = Nothing
times (like 50 times) to create 50 threads, the message did not get pass
thru ProcessMessage.
For example: strBuffer = "#TRADE, D1410-123456, BUY, 1, ESM7, DAY, LIMIT,
1490.00, , , 0, 0, 0, 0, 0, links |52994/25/2007 10:47:17 AM !A", when I
trigger to create many threads (like 50), this message did not get to sub
ProcessMessage in clsEachMessage.
I have added Thread.Sleep(0) after the Start method of the thread.
What is the best way to do the thread so that every message get pass thru to
it ?
Is there a maximum number of thread that I can create ?
Shall I use thread pool instead of creating a new thread each time ?
Thank you very much.
Dim EachMessageThread As Threading.Thread = Nothing
Dim clsEachMessage As New EachMessage
clsEachMessage.sMessage = strBuffer
EachMessageThread = New Threading.Thread(AddressOf
clsEachMessage.ProcessMessage)
threadCount += 1
EachMessageThread.Name = "Thread " & threadCount.ToString()
EachMessageThread.Start()
Thread.Sleep(0)
Public Class EachMessage
Public sMessage As String
Public Sub ProcessMessage()
Dim swError As StreamWriter
swLog = New StreamWriter(sPath & "\log\Input.txt", True)
swLog.Write(sMessage & vbCrLf)
swLog.Close()
swLog = Nothing