Home > Net >  Repeat the same thread timer
Repeat the same thread timer

Time:11-13

C # write a Windows service, the service time to invoke a method, the method will be two new threads to invoke other methods, will now have a thread not over, then service to restart time regularly, and built the same method of thread, how can you judge the thread state, want to be in time when restarting the destruction of this thread

CodePudding user response:

Extreme cases, every time all have no result, stopped in front of you, so you may never get the results,
Please wait for the front end, and of course to the previous set for the end of the timeout (maximum execution time, your timer 2 or 3 cycles)

Or

Current limit queue, you don't hurry to produce thread, first add tasks to the current limit queue, in consumption by the scheduler tuning his
(the current limit, extreme situation, the production of miss consumption, the queue will be infinite, the result is a collapse, another purpose of current limit is at the same time, you can check the quantity accumulation, the task if you found other events in the full state for a long time, and there is a new task to join, you need to report to the police log writing, at this time, you know, or you have the two 2 threads don't too late, need to optimize, either you're the timer does not conform to the actual production capacity, need to adjust the time)

CodePudding user response:

refer to the original poster tracy1421 response:
c # write a Windows service, the service time to invoke a method, the method will be two new threads to invoke other methods, will now have a thread not over, then service to restart time regularly, and built the same method of thread, how can you judge the thread state, want to be in time start again destroyed this thread

Timer specific it is, no matter that round had finished, the time interval will start a new thread
If none of the previous round after, in fact, have to ask two questions
1. The unfinished will influence the execution of the round after?
2. The timer interval is too small? The optimization program or augmenting the timer interval
  •  Tags:  
  • C#
  • Related