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 8508613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:12:35+00:00 2026-06-11T03:12:35+00:00

The Problem I have a constant flow of datapackages. Every time a new package

  • 0

The Problem

I have a constant flow of datapackages. Every time a new package is incoming (100 ms interval) an event pops in which I send the package to a class to process the data and visualize it. Unfortunately, it could happen that the process of a package is aborted if a new package was sent before the current one has been processed.

What I have now

Is a Code that is used as dll for another program.
When I started coding the dll, I was new to c# so I didn’t want to do it too complicated. Everything is working but I faced some ugly Frame skips (in my visualization part) if the cpu is very busy.

I have several classes and one of them is handling all packages. This class has round about 50 attributes 25 functions and 1000 lines of code. only 6 functions are needed for the calculations.
The rest is setting the attributes correctly (if the user changes settings).

What I need to change

So now I want to buffer all incoming data by using a List.
The list should be handled by another thread. So it is very unlikely that writing the data to the list takes longer than 100 ms ^^ (2 arrays with ca. 40 elements each that should be equal to nothing)

What I have in mind

Splitting the mentioned class into 2 separate classes.
One that handles the packages and one that handles the settings. So I would split the user and the “program” input.
Creating a thread that uses the “package handling” class to process the buffered data.

What I have no clue about

Since the settings class contains important attributes that are needed by the handling class I don’t know how to do it best, because The handling class also needs to change/fill buffers in the settings class. But this one will be invoked by the main thread. Or is it better to not split the setting and handling class and leave it as it is? I am not so familiar with threading and read the first chapter of this free e-book Threading in C#

  • 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-06-11T03:12:36+00:00Added an answer on June 11, 2026 at 3:12 am

    I would just add a queue and implement a thread for the processing. That will help you with the skips and requires little change. Refactoring the code by splitting settings apart seems like a lot of work with little benefit and possible new bugs.

    To add the queue;

    • Create a ConcurrentQueue (this is threadsafe lifo, which is what you need)

          var cq=new ConcurrentQueue<Packets>();
      
    • Add all your datapackets to that Queue

           cq.Enqueue(newPacket);
      
    • Create another thread that loops around and processes the Queue

           if (cq.TryDequeue(out newPacket)) 
           { 
              // Visualize new packet
           }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have constant problem with cookies on my Django site which is set up
Problem: Have made a small mail program which works perfectly on my developer pc
Here is a problem I have encountered. I have jsp page which has a
I have problem with List<Image> List<Image> _Images = new List<Image>(); int currIndex = 0;
have a problem creating my new table in SqlLite3 I have created this migration
I am first going to describe the problem which I have, and then give
Problem I have a file which contains such text (nothing else) 2010-10-05 I would
Following situation: I have an array with some constant values, which represent ranges. A
I have a problem which isn't really that big, but still gives me some
I have a problem with whether making class members constant or not. Let me

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.