c# - Prioritize threads. -


so application has collection of points. each point has checkstatustimer, checknewdatatimer, , checkdevcetimer (they system.timers). point has sampletime property. if sample time set 30 seconds then:

checkstatustimer.interval = sampletime/4;   // ~7 seconds, reset , start on checknewdatatimer.interval = sampletime/2;  // 15 seconds, reset , start on checkdevcetimer.interval = sampletime;      // 30 seconds, reset , start on 

all timers trigger function pull data connected (modbus tcp) device , takes time. can imagine more points add more threads scheduled , process time user calls increase.

i create task process user incoming messages.

task.factory.startnew(() => this.proccessmessage(session, value)); 

i have tried set (i know bad idea)

thread.currentthread.priority = threadpriority.highest;  

but didn work, , tried to

    var worker = new thread(() = this.proccessmessage(session, value))                      {                          priority = threadpriority.highest                      };     worker.start(); 

it didn't work well, there not differences on processes times. question how can prioritize thread or this.proccessmessage(session, value) method, on timers threads/methods. when user makes call respond right away no delay regardless of size of collection.

looks need queues here. 1 high priority queue , 1 low priority queue. timer threads should post low priority queue. user messages should go high priority queue. , process these queues can have pool of threads reading queue , processing data, processing high priority queue first. approach might work problem.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -