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
// Allows the async Task method to safely run on a different thread while not awaiting its completion
158
-
159
164
// onException: If a WebException is thrown, print its StatusCode to the Console. **Note**: If a non-WebException is thrown, it will not be handled by `onException`
160
-
161
165
// Because we set `SetDefaultExceptionHandling` in `void InitializeSafeFireAndForget()`, the entire exception will also be printed to the Console
- Added support for `event Action` and `event Action<T>`
22
-
- Added support for `.SafeFireAndForget<TException>()`
23
-
- Added `SafeFireAndForgetExtensions.SetDefaultExceptionHandling(Action<Exception> onException)` to set a default action for every call to `SafeFireAndForget`
24
-
- Added `SafeFireAndForgetExtensions.Initialize(bool shouldAlwaysRethrowException = false)`. When set to `true` will rethrow every exception caught by `SafeFireAndForget`. Warning: `SafeFireAndForgetExtensions.Initialize(true)` is only recommended for DEBUG environments.
25
-
- Added support for `Exception innerException` to `InvalidCommandParameterException`
26
-
- Breaking Change: Changed default value to `continueOnCapturedContext = false`. This improves performance by not requiring a context switch when `.SafeFireAndForget()` and `IAsyncCommand` have completed.
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.AsyncCommand`1"/> class.
23
21
/// </summary>
@@ -26,18 +24,16 @@ public sealed class AsyncCommand<T> : IAsyncCommand<T>
26
24
/// <param name="onException">If an exception is thrown in the Task, <c>onException</c> will execute. If onException is null, the exception will be re-thrown</param>
27
25
/// <param name="continueOnCapturedContext">If set to <c>true</c> continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to <c>false</c> continue on a different context; this will allow the Synchronization Context to continue on a different thread</param>
28
26
publicAsyncCommand(Func<T,Task>execute,
29
-
Func<object,bool>canExecute=null,
30
-
Action<Exception>onException=null,
27
+
Func<object?,bool>?canExecute=null,
28
+
Action<Exception>?onException=null,
31
29
boolcontinueOnCapturedContext=false)
32
30
{
33
31
_execute=execute??thrownewArgumentNullException(nameof(execute),$"{nameof(execute)} cannot be null");
/// Initializes a new instance of the <see cref="T:TaskExtensions.MVVM.AsyncCommand`1"/> class.
99
101
/// </summary>
@@ -102,18 +104,16 @@ public sealed class AsyncCommand : IAsyncCommand
102
104
/// <param name="onException">If an exception is thrown in the Task, <c>onException</c> will execute. If onException is null, the exception will be re-thrown</param>
103
105
/// <param name="continueOnCapturedContext">If set to <c>true</c> continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to <c>false</c> continue on a different context; this will allow the Synchronization Context to continue on a different thread</param>
104
106
publicAsyncCommand(Func<Task>execute,
105
-
Func<object,bool>canExecute=null,
106
-
Action<Exception>onException=null,
107
+
Func<object?,bool>?canExecute=null,
108
+
Action<Exception>?onException=null,
107
109
boolcontinueOnCapturedContext=false)
108
110
{
109
111
_execute=execute??thrownewArgumentNullException(nameof(execute),$"{nameof(execute)} cannot be null");
$"Invalid type for parameter. Expected Type {excpectedType}, but received Type {actualType}";
52
+
staticstringCreateErrorMessage(TypeexcpectedType,TypeactualType)=>$"Invalid type for parameter. Expected Type {excpectedType}, but received Type {actualType}";
0 commit comments