Results 1 to 3 of 3

Thread: Running long term data grab from separate thread

  1. #1

    Thread Starter
    Hyperactive Member nickwrs's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta, Ga
    Posts
    398

    Running long term data grab from separate thread

    Hi All,
    I have an application where I need to grab data from a high speed serial buffer. To process it in time I really do need to do something like the following:

    Essentially start a thread that continually waits for data, collects it as it comes in, processes it in situ and then spits occasional data packets back to the GUI for display/control

    I did have this run on a system.threading.timer but it randomly would cut out for 20-30 ms and my buffer overflowed.

    Code:
        Public Sub StartDataGrab()
            CancelDataGrab = False
            Dim Thread1 As New System.Threading.Thread(AddressOf doDataGrabs)
            Thread1.Start()
    
        End Sub
    
        Public Sub doDataGrabs()
            Do While Not CancelDataGrab
                'Get data from Serial Buffer and Process
                'Async send processed data back to GUI
                'Run entire time UI thread is running
            Loop
        End Sub
    Questions:
    1) is this safe to let run for a long time? It seems like it would be safe. Just wondering if anyone had any experience, this application will be meant to run for weeks at a time.

    2) Is there a better way to do this? Tasks, or the like?

    Thanks in advance,
    Nick

    PS, not a traditional serial card so some of the built in .net handling of serial cards can't be used.

  2. #2
    Addicted Member
    Join Date
    Oct 2008
    Location
    USA
    Posts
    150

    Re: Running long term data grab from separate thread

    BackgroundWorker maybe?
    Think.... Question.....

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Running long term data grab from separate thread

    What is high-speed?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width