Example #1
0
 public ThreadStockWrapper(int threads, string function, ArrayList stockSymbols)
 {
     iThreads        = threads;
     sFunction       = function;
     arStockSymbols  = stockSymbols;
     arThreadStorage = new ArrayList[threads];
     arResults       = new ArrayList[threads];
     sdDrones        = new StockDrone[threads];
     tThreads        = new Thread[threads];
     for (int i = 0; i < threads; i++)
     {
         arResults[i]       = new ArrayList();
         arThreadStorage[i] = new ArrayList();
     }
     for (int i = 0; i < stockSymbols.Count; i++)
     {
         arThreadStorage[i % threads].Add(stockSymbols[i]); // distributing the load equally.
     }
     for (int i = 0; i < threads; i++)
     {
         sdDrones[i] = new StockDrone(arThreadStorage[i], arResults[i]); //prep each drone, storage of symbols, and results storage.
         tThreads[i] = new Thread(sdDrones[i].dispatchFunction);         // assign each drone as a thread.
     }
 }
Example #2
0
 public ThreadStockWrapper(int threads, string function, ArrayList stockSymbols)
 {
     iThreads = threads;
     sFunction = function;
     arStockSymbols = stockSymbols;
     arThreadStorage = new ArrayList[threads];
     arResults = new ArrayList[threads];
     sdDrones = new StockDrone[threads];
     tThreads = new Thread[threads];
     for (int i = 0; i < threads; i++)
     {
         arResults[i] = new ArrayList();
         arThreadStorage[i] = new ArrayList();
     }
     for (int i = 0; i < stockSymbols.Count; i++)
     {
         arThreadStorage[i % threads].Add(stockSymbols[i]); // distributing the load equally.
     }
     for (int i = 0; i < threads; i++)
     {
         sdDrones[i] = new StockDrone(arThreadStorage[i], arResults[i]); //prep each drone, storage of symbols, and results storage.
         tThreads[i] = new Thread(sdDrones[i].dispatchFunction); // assign each drone as a thread.
     }
 }