big array and threading  
Author Message
JockeOlsson





PostPosted: Visual C# General, big array and threading Top

i'm developing a software to read values from a USB unit thats connected through a virtual COM port.

I have an static array with size of 50000. I store my specialized object containing seven variables in this array.

This array is filled with values as I make my "thing" with my external unit.

Now the problem is that it's really slow to collect values.

My readings come in with a speed of about 1 value each 2 milliseconds.

I wrote my object as a struct to speed things up.

Would it help to make my reading in a separate thread from my app



Visual C#7  
 
 
RizwanSharp





PostPosted: Visual C# General, big array and threading Top

I have an static array with size of 50000. I store my specialized object containing seven variables in this array.

Each time you have 50,000 objects to store in the Array ot you have varying nubmer of objects to store 7 Variables means 7 Fields in each Object

If number of objects are not always constant then use List<T> class to store you objects!

This array is filled with values as I make my "thing" with my external unit.

Now the problem is that it's really slow to collect values.

My readings come in with a speed of about 1 value each 2 milliseconds.

I wrote my object as a struct to speed things up.

Would it help to make my reading in a separate thread from my app

Yes you can split large number of arrays to 2-3 Threads or Better Background Worker components to Read the data from the List<>

Also list class provides many methods, like BinarySearch, Find. May be you can use them in efficient way but all depends on your situation what what your want to do and how you are reading data.

Better understanding will be then when you share piece of Code!

Best Regards,



 
 
ahmedilyas





PostPosted: Visual C# General, big array and threading Top

remember, threading is expensive so only use it when you need to.

 
 
JockeOlsson





PostPosted: Visual C# General, big array and threading Top

i'll get back with some code in a few hours.. .thanks