SQL Server Developer Center >
SQL Server Forums
>
.NET Framework inside SQL Server
>
Slow thread while counting lines i/o
Slow thread while counting lines i/o
Hallo,
I have a problem with a thread that i made. I have a form which of course runs on his own thread. From that place i want to start a new thread which will count some lines in a tab separated file. The reason why i start a new thread is because i don’t want the counting of the lines to slow other processes on my form. Unfortunately this happens anyway.
I still can’t find out why the thread slows my other processes in the original form. The whole idea of a new thread is to avoid slowlines on other processes....Does someone have any idea?
Public Sub LogThreadStart() 'prepare/start new thread to log data 'this way the slowlines of datalogging don't interupt the other processes. Dim startThreadLogSub As New System.Threading.Thread(AddressOf Me.ThreadLogSub) startThreadLogSub.Priority = Threading.ThreadPriority.Normal startThreadLogSub.Start(Me.DsDTSettings.Tables("dtDataLogSettings").Rows(0).Item("clmnLogFileName").ToString()) End Sub Private Sub ThreadLogSub(ByVal Filnm As String) 'start LogFrmDLL.LogDataNow LogFrmDLL.LogDataNow(Me.QueueDataLog, Filnm, MaxLogFileLinesSurpassed) End Sub Public Module LogFrmDLL Public Sub LogDataNow(ByVal QueueLog As Queue, ByVal FileNameDataLog As String, ByRef MaxLogFileLinesSurpassed As Boolean) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' if the logfile >= then x lines then ' change MaxLogFileLinesSurpassed to true, in that way a new file ' is created when in HdForm.TimerDataLog_Tick Using FileReader2 As New Microsoft.VisualBasic.FileIO.TextFieldParser(FileNameDataLog) FileReader2.Delimiters = New String() {" "} While Not FileReader2.EndOfData FileReader2.ReadLine() If FileReader2.LineNumber >= 70000 Then MaxLogFileLinesSurpassed = True End While End Using ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' End Sub End Module
Answers
- Done. Just read the whole file in a string and then split ect. Don't use the while loop.
- Marked As Answer bybochelie Wednesday, October 28, 2009 8:51 AM
All Replies
- How many CPU processors/cores do you have? If you only have one, then all of the threads on your PC have to share it.
-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc. "Performance is our middle name."
Please! Remember to Vote all helpful replies as Helpful - Done. Just read the whole file in a string and then split ect. Don't use the while loop.
- Marked As Answer bybochelie Wednesday, October 28, 2009 8:51 AM


