Note that there are some explanatory texts on larger screens.

plurals
  1. POc# How to restructure my program for threading
    primarykey
    data
    text
    <h2>The Problem</h2> <p>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.</p> <h2>What I have now</h2> <p>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. </p> <p>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).</p> <h2>What I need to change</h2> <p>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)</p> <h2>What I have in mind</h2> <p>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.</p> <h2>What I have no clue about</h2> <p>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 <a href="http://www.albahari.com/threading/" rel="nofollow">Threading in C#</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload