pankaj.garg 0 Junior Poster in Training

Dear All,

I am working on CE5 device and developing my application on .net Compact Framework 2.
While using threads I am facing a strange problem -

My thread terminates unexpectedly when I call a function from it which does a serial communication.

Any suggestions why this might be happening? In general what are the major conditions for a thread to get terminated??

My application in brief -

I am calling my thread from main form -

stopreadingserial = False
SerialComThread = New Thread(AddressOf CommunicationClass.SerialCommunication)
SerialComThread.Start()

My thread is defined in a communication class

Public Shared Sub SerialCommunication()

Do While (stopreadingserial = False)
BoolRet1 = CommunicationClass.GetValuesSerial
Thread.Sleep(300)

Loop

End Sub

The GetValuesSerial function calls the function which does the actual communication with serial port

Public Shared Function GetValuesSerial() As Boolean
For localCount1 As Integer = 1 To 8
BoolRet1 = CommunicationClass.TempControllerRead(localCount1 + 10, localCount1, 1)
Sleep(50)
BoolRet1 = CommunicationClass.TempControllerRead(localCount1 + 18, localCount1, 2)
Next
GetValuesSerial = True
End Function

Please help !!

Pankaj Garg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.