Question Application lock-up

Budius

Well-known member
Joined
Aug 6, 2010
Messages
137
Location
UK
Programming Experience
3-5
hi,

I'm have a quite big application which have 2 serial ports and access 1 DB (running on Background workers). I'm experiencing some random locks while the application is running and I started looking for something that could cause it.

One of the obvious possibilities would be if I had in the GUI thread some While_End that would never return.
I have one While_End in my GUI thread but IMHO it does not look like it would lock, so I want your opinion: Does the code below looks like will lock?? If 'yes', Why ?

VB.NET:
    Private Sub CommsReader_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles CommsReader.DoWork

        While Not CommsReader.CancellationPending
            ' Read
            If Serial.ReadMessage() Then         ' If read successful
                CommsReader.ReportProgress(1)   ' Reports 1 = good read, update screen
            Else                                ' If Timeout
                CommsReader.ReportProgress(-1)  ' Report -1 = time out
                Exit While                      ' Stops the coms reader
            End If

            ' Awaits for next message
            r.Sleep(800)

        End While
    End Sub

    Public Function StopWorker() As Boolean
        CommsReader.CancelAsync()           ' Cancels the reader thread and awaits
        While CommsReader.IsBusy            ' Awaits the thread to end
            r.Sleep(200)
            Try
                Application.DoEvents()
            Catch ex As Exception
                r.ErrorLog(ex.Message)
            End Try
        End While

        StopWorker = True
    End Function

This StopWorker method is called by different areas of my application when they have to use the serial port to send commands.

From my point of view, the only way for the BGWorker not to see the CancellationPending it would be if the Serial.ReadMessage() never returns, but that method is a simply:

VB.NET:
            For i = 0 To 18
                WTU.Analogues(i) = WTUConn.Read(", ")
            Next i
            WTU.Analogues(19) = WTUConn.Read(vbCr)
plus a few extra Try-Catch; Return True or False bits.


Does anyone can imagine a scenario where this While_End would not return ??

thanks
 
In case anyone is curious:

it seems that the problem at the end was a corrupted installation.
This machine was installed, uninstalled, reinstalled, uninstalled, installed several times during debugging, always deployed with the Click-Once and usually from different locations (publish to myDesktop and then manually putting the files there), and even changed the application name a couple of times.
V0.xx didn't locked
V1.00 was locking up.
V1.001 I added some logs to a text file to try to find the source and still was locking up, no clues on the logs.
V1.002 I added more logs and deleted the cache from the ClickOnce installation before install it. No more locks.
V1.003 Just removed the logs, so basically is the V1.00 again.

Cheers.

ps.: how do I change my post to "Resolved" ?
 
Back
Top