Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3787772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:53:36+00:00 2026-05-19T11:53:36+00:00

VB.NET, .NET 4 Hello all, I have a List(Of Byte) that is filled with

  • 0

VB.NET, .NET 4

Hello all,

I have a List(Of Byte) that is filled with bytes from the serial buffer on a SerialPort.DataRecieved Event. I then try to parse the data. Part of the parsing process involves deleting elements of the List(Of Byte). Should I be concerned about the List being modified by a DataRecieved Event that might be raised during the parsing process? I realize that probably depends on what I’m trying to do, but, assuming I should be concerned (e.g., the parsing process needs List.Count to not change until parsing is finished), how should I go about making sure any Add calls wait until the parser is done? I guess the answer is something like SyncLock, but I’ve never really understood how SyncLock works. Any basic help would be appreciated!

Thanks in advance,
Brian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:53:37+00:00Added an answer on May 19, 2026 at 11:53 am

    Well, it’s not the greatest use of CPU cycles, removing bytes from a List(Of Byte) is an O(n) operation. Making the overall processing step O(n^2). It is still quite difficult to put any kind of pressure on the cpu doing so, serial ports are glacially slow. You should only ever modify working code if you have measured it to be a perf problem.

    If you’re not there yet then consider creating a new array or List from the old one. That’s O(n), the extra storage cannot hurt considering the slow data rates. The code should be cleaner too.

    As far as threading goes, be sure to do this in the DataReceived handler. That’s thread-safe and avoids putting undue pressure on the UI thread in case you invoke.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all i have code from open source project that im integrating into my
VB.NET 2010, .NET 4 Hello all, I have a System.Timers.Timer object that does some
Hello I know all about http://www.php.net/manual/en/function.http-build-query.php to do this however I have a little
I have a C# .Net 3.5 application that sends a multicast Hello packet to
Hello to all I am here facing some situation of detecting url in asp.net
I need to convert all of the following forms into .NET Uri object: hello.world
hello i have created one windows application in c# .net and its working fine
hello I'm new to PHP programming and I migrated from ASP .net to PHP..
Hello everyone I've been trying to put some objects in an ASP.NET list box
If I have a list of data: $a = hello; $b= 4f60; $c =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.