You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
12
12
- Allow `ManualTimeProvider.Start` to be set using property initializers.
13
13
14
+
- Made the timer type created by `ManualTimeProvider`, the `ManualTimer` type, public, and introduced a protected method `CreateManualTimer` on `ManualTimeProvider`. This enables advanced scenarioes where a custom `ManualTimer` is needed.
15
+
16
+
A custom implementation of `ManualTimer` can override the `Change` method and add custom behavior to it.
17
+
18
+
Overriding `CreateManualTimer` makes it possible to intercept a `TimerCallback` and perform actions before and after the timer callback has been invoked.
19
+
14
20
## [1.0.0-rc.1]
15
21
16
22
- Updated Microsoft.Bcl.TimeProvider package dependency to rc.1 version.
Createsanew [System.Threading.ITimer](https://docs.microsoft.com/en-us/dotnet/api/System.Threading.ITimer 'System.Threading.ITimer') instance, using [System.TimeSpan](https://docs.microsoft.com/en-us/dotnet/api/System.TimeSpan 'System.TimeSpan') values to measure time intervals.
Getsthenexttimethetimercallbackwillbeinvoked, or[null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null') if the timer is inactive.
When [IsActive](TimeProviderExtensions.ManualTimer.md#TimeProviderExtensions.ManualTimer.IsActive'TimeProviderExtensions.ManualTimer.IsActive') returns [true](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool 'https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool'), [CallbackTime](TimeProviderExtensions.ManualTimer.md#TimeProviderExtensions.ManualTimer.CallbackTime 'TimeProviderExtensions.ManualTimer.CallbackTime') is not [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null').
Copy file name to clipboardExpand all lines: src/TimeProviderExtensions/ManualTimeProvider.cs
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -174,13 +174,29 @@ public override DateTimeOffset GetUtcNow()
174
174
/// To move time forward for the returned <see cref="ITimer"/>, call <see cref="Advance(TimeSpan)"/> or <see cref="SetUtcNow(DateTimeOffset)"/> on this time provider.
/// Creates an instance of a <see cref="ManualTimer"/>. This method is called by <see cref="CreateTimer(TimerCallback, object?, TimeSpan, TimeSpan)"/>.
186
+
/// </summary>
187
+
/// <remarks>
188
+
/// Override this methods to return a custom implementation of <see cref="ManualTimer"/>. This also allows for intercepting and wrapping
189
+
/// the provided timer <paramref name="callback"/> and <paramref name="state"/>, enabling more advanced testing scenarioes.
190
+
/// </remarks>
191
+
/// <param name="callback">
192
+
/// A delegate representing a method to be executed when the timer fires. The method specified for callback should be reentrant,
193
+
/// as it may be invoked simultaneously on two threads if the timer fires again before or while a previous callback is still being handled.
194
+
/// </param>
195
+
/// <param name="state">An object to be passed to the <paramref name="callback"/>. This may be null.</param>
196
+
/// <param name="timeProvider">The <see cref="ManualTimeProvider"/> which is used to schedule invocations of the <paramref name="callback"/> with.</param>
0 commit comments