Threading priority (maybe?)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hamil

    Threading priority (maybe?)

    I have a form that contains the attached code that starts a new thread.
    Thewre are three routines. StartMomnitorin g starts the thread DoMonitor, and
    StopMonitor stops the thread. The "SendRec" routine sends amessage out a
    Tcp/Ip socket and returns the returned value. As the DoMonitor thread shows,
    there is a sleep of 1 msec so I would expect a rate depending on the
    internet latency. Here is the problem..

    When started, I get an exchange rate of about 2 per second. However, if I
    right click on the title barof the form, I get a pop up window with move,
    close, etc options, and the rate increases to about 30 per second. I have
    thought about trhread priority but changing the priority makes no difference.

    Any thoughts anybody??


    Public Sub StartMonitoring ()
    Dim t1 As New Thread(AddressO f DoMonitor)
    Console.WriteLi ne("starting thread")
    't1.Priority = ThreadPriority. Highest
    t1.Start()
    End Sub

    Public Sub StopMonitoring( )
    Console.WriteLi ne("stopping thread")
    RunStop = 0
    End Sub

    Sub DoMonitor()
    Dim s As String
    Dim ss As String
    Dim p() As String
    Dim pp As String
    Dim I As Int32 = 0
    Dim xx As Integer
    RunStop = 1
    Dim OFile As New StreamWriter(Ap plication.Start upPath &
    "\Data\LogFile. txt")
    Do
    If I = Count Then I = 0
    s = Ant0.WriteRead( Cmd(I))
    ss = Now.ToString("h h:mm:ss") & "," & s
    Console.WriteLi ne(ss)
    OFile.WriteLine (ss)
    MonBox.Text = ss
    'Thread.Sleep(1 0)
    If RunStop = 0 Then Exit Do
    I += 1
    Loop
    OFile.Close()
    End Sub


Working...