Click here to Skip to main content
15,908,776 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhow to send mail by visual basic ? Pin
Golden Jing8-Dec-09 1:02
Golden Jing8-Dec-09 1:02 
AnswerRe: how to send mail by visual basic ? Pin
Paramu19738-Dec-09 4:35
Paramu19738-Dec-09 4:35 
GeneralRe: how to send mail by visual basic ? [modified] Pin
Golden Jing8-Dec-09 15:21
Golden Jing8-Dec-09 15:21 
QuestionSave Csv or excel file to sql using vb6.0 Pin
Parag Raibagkar7-Dec-09 18:49
Parag Raibagkar7-Dec-09 18:49 
AnswerRe: Save Csv or excel file to sql using vb6.0 Pin
Eddy Vluggen8-Dec-09 0:26
professionalEddy Vluggen8-Dec-09 0:26 
GeneralRe: Save Csv or excel file to sql using vb6.0 Pin
Parag Raibagkar8-Dec-09 20:04
Parag Raibagkar8-Dec-09 20:04 
GeneralRe: Save Csv or excel file to sql using vb6.0 Pin
Dave Kreskowiak9-Dec-09 3:52
mveDave Kreskowiak9-Dec-09 3:52 
QuestionMultithreaded App using 100% CPU...how can i make it use less? [modified] Pin
Aaron @ Think Software7-Dec-09 0:11
professionalAaron @ Think Software7-Dec-09 0:11 
I have an application using multithreading to read and parse a stream of data from the serial port into packets and extract information out of it to be displayed by the main thread using DirectX interface.

The application is working properly etc, but the thread that reads and parses the com port information is utilising close to 100% cpu usage which is rather annoying me and im not sure what to do about it...a fragment of the code is posted below:

Packets are streamed from the device at 100ms intervals, and the program can't afford to back buffer as the information it is displaying needs to be live, nor can it miss a packet as it needs to check each packet for a particular condition that doesnt get repeated once it occurs...

Public Sub CommReadThread()

    Dim bByte As Byte, bPacket(73) As Byte, lResult As Long, tsData As TimeSpan

    Try

        LinkDev = New SerialPort("COM1", 19200)
        LinkDev.Open()

    Catch ex As Exception
        MsgBox("COM ERROR: " & ex.Message)
        Exit Sub
    End Try

    While bStop = False

        tsData = DateTime.Now.Subtract(_iLastData)
        CommIdleTime = tsData.TotalMilliseconds

        CommBufferSize = LinkDev.BytesToRead

        'If no data received for period, flag as disconnected
        If CommIdleTime >= _dataTiemout Then
            bIsConnected = False
        Else
            bIsConnected = True
        End If

        If CommBufferSize > 0 Then

            If iFFCount = 2 Then
                'found a header, read the rest of the packet
                If CommBufferSize >= 70 Then

                    lResult = LinkDev.Read(bPacket, 0, 70)
                    _iLastData = DateTime.Now

                    'Build the packet putting the header back in there for processing
                    For x As Integer = UBound(bPacket) To 2 Step -1
                        bPacket(x) = bPacket(x - 2)
                    Next

                    bPacket(0) = &HFF
                    bPacket(1) = &HFF
                    bPacket(2) = &HFF

                    LinkPacket = New Packet(bPacket)

                    '...do packet processing, the New function of the packet class processes it...

                    LinkPacket = Nothing

                    iFFCount = 0

                End If

            Else
               'Find a header in the data stream

                bByte = LinkDev.ReadByte()
                _iLastData = DateTime.Now

                If iFFCount > 0 Then
                    If Hex(bByte) <> "FF" Then
                        iFFCount = 0
                    End If
                End If

                If Hex(bByte) = "FF" Then
                    iFFCount += 1
                End If

            End If

        End If

    End While

End Sub


modified on Monday, December 7, 2009 6:59 AM

AnswerRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
David Skelly7-Dec-09 0:40
David Skelly7-Dec-09 0:40 
GeneralRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
Aaron @ Think Software7-Dec-09 0:44
professionalAaron @ Think Software7-Dec-09 0:44 
GeneralRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
David Skelly7-Dec-09 2:35
David Skelly7-Dec-09 2:35 
AnswerRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
Luc Pattyn7-Dec-09 0:43
sitebuilderLuc Pattyn7-Dec-09 0:43 
GeneralRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
Aaron @ Think Software7-Dec-09 0:59
professionalAaron @ Think Software7-Dec-09 0:59 
GeneralRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
Luc Pattyn7-Dec-09 1:11
sitebuilderLuc Pattyn7-Dec-09 1:11 
GeneralRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
N a v a n e e t h7-Dec-09 3:03
N a v a n e e t h7-Dec-09 3:03 
GeneralRe: Multithreaded App using 100% CPU...how can i make it use less? Pin
Luc Pattyn7-Dec-09 3:17
sitebuilderLuc Pattyn7-Dec-09 3:17 
QuestionHow to print out a Quotation mark. Pin
thebiostyle6-Dec-09 16:16
thebiostyle6-Dec-09 16:16 
AnswerRe: How to print out a Quotation mark. Pin
Dave Kreskowiak6-Dec-09 17:47
mveDave Kreskowiak6-Dec-09 17:47 
QuestionHow to MDI child form call method from MID parent form??? Pin
cotdot111116-Dec-09 15:49
cotdot111116-Dec-09 15:49 
AnswerRe: How to MDI child form call method from MID parent form??? Pin
dan!sh 6-Dec-09 17:44
professional dan!sh 6-Dec-09 17:44 
AnswerRe: How to MDI child form call method from MID parent form??? Pin
Andy_L_J6-Dec-09 17:58
Andy_L_J6-Dec-09 17:58 
Question[Message Deleted] Pin
Diana shorafa6-Dec-09 8:02
Diana shorafa6-Dec-09 8:02 
AnswerRe: Graduation Project Pin
Dave Kreskowiak6-Dec-09 15:38
mveDave Kreskowiak6-Dec-09 15:38 
GeneralRe: Graduation Project Pin
Paul Conrad7-Dec-09 10:02
professionalPaul Conrad7-Dec-09 10:02 
AnswerRe: Graduation Project Pin
Mycroft Holmes6-Dec-09 18:57
professionalMycroft Holmes6-Dec-09 18:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.