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)