Setting the timer interval to infinite

I have a method that associates BO Connection.AliveIntervalwith System.Timers.Timer(.NET 2 ).

Some connection is always connected.

Is it possible in this case to establish

if (myConnection.AliveInterval == Connection.TimeInfinite)
{
    myTimer.Interval = double.PositiveInfinity;
}

?

Should I expect the timer to throw exceptions or to ever exceed the Elapsed event?

+3
source share
3 answers

MSDN :

The value must be greater than zero, and less than or equal to Int32.MaxValue

An ArgumentExceptionwill be thrown when the interval is greater than Int32.MaxValue, and the timer is currently on. If the timer is not currently enabled, the exception is not until it is enabled.

, PositiveInfinity , .

PositiveInfinity. ArgumentException PositiveInfinity.

0

, , MonoDevelop VS System.Timers.Timer:

, .

Int32, UInt32 TimeSpan. , Infinite.

Timeout.Infinite .

, :

-. , .

. , , . myTimer.Stop(), @spender myTimer.Enabled = false, @Bolu.

+7

Why not myTimer.Stop()?

0
source

Source: https://habr.com/ru/post/1768966/


All Articles