How to prevent a C# System.Timers timer event from blocking subsequent events?

I have a C# application that uses a System.Timers timer that repeatedly calls a function. The problem is, depending on the workload, if the processing from a function call reaches a certain CPU usage percentage (98-100%), any subsequent events are blocked.

Is there a way to prevent such a scenario so that events are not blocked?

For example, the timer's event handler is a function that executes dynamic code, which may take some time and resources to process. During such processing a boolean is set to true which causes any subsequent event calls to write to a log file. Once an event's processing has reached a high CPU usage though, additional events will not write to the log file.


Yes, set the Timers property AutoReset to true.

Read: https://msdn.microsoft.com/en-us/library/system.timers.timer(v=vs.110).aspx

链接地址: http://www.djcxy.com/p/68072.html

上一篇: C#:实现一个Action +事件

下一篇: 如何防止阻止后续事件的C#System.Timers计时器事件?