@@ -377,7 +377,7 @@ protected bool SetPropertyAndNotifyOnCompletion([NotNull] ref TaskNotifier? task
377
377
// instance. This will result in no further allocations after the first time this method is called for a given
378
378
// generic type. We only pay the cost of the virtual call to the delegate, but this is not performance critical
379
379
// code and that overhead would still be much lower than the rest of the method anyway, so that's fine.
380
- return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new TaskNotifier ( ) , newValue , static _ => { } , propertyName ) ;
380
+ return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new TaskNotifier ( ) , newValue , null , propertyName ) ;
381
381
}
382
382
383
383
/// <summary>
@@ -441,7 +441,7 @@ protected bool SetPropertyAndNotifyOnCompletion([NotNull] ref TaskNotifier? task
441
441
/// </remarks>
442
442
protected bool SetPropertyAndNotifyOnCompletion < T > ( [ NotNull ] ref TaskNotifier < T > ? taskNotifier , Task < T > ? newValue , [ CallerMemberName ] string ? propertyName = null )
443
443
{
444
- return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new TaskNotifier < T > ( ) , newValue , static _ => { } , propertyName ) ;
444
+ return SetPropertyAndNotifyOnCompletion ( taskNotifier ??= new TaskNotifier < T > ( ) , newValue , null , propertyName ) ;
445
445
}
446
446
447
447
/// <summary>
@@ -476,10 +476,10 @@ protected bool SetPropertyAndNotifyOnCompletion<T>([NotNull] ref TaskNotifier<T>
476
476
/// <typeparam name="TTask">The type of <see cref="Task"/> to set and monitor.</typeparam>
477
477
/// <param name="taskNotifier">The field notifier.</param>
478
478
/// <param name="newValue">The property's value after the change occurred.</param>
479
- /// <param name="callback">A callback to invoke to update the property value.</param>
479
+ /// <param name="callback">(optional) A callback to invoke to update the property value.</param>
480
480
/// <param name="propertyName">(optional) The name of the property that changed.</param>
481
481
/// <returns><see langword="true"/> if the property was changed, <see langword="false"/> otherwise.</returns>
482
- private bool SetPropertyAndNotifyOnCompletion < TTask > ( ITaskNotifier < TTask > taskNotifier , TTask ? newValue , Action < TTask ? > callback , [ CallerMemberName ] string ? propertyName = null )
482
+ private bool SetPropertyAndNotifyOnCompletion < TTask > ( ITaskNotifier < TTask > taskNotifier , TTask ? newValue , Action < TTask ? > ? callback , [ CallerMemberName ] string ? propertyName = null )
483
483
where TTask : Task
484
484
{
485
485
if ( ReferenceEquals ( taskNotifier . Task , newValue ) )
@@ -507,7 +507,10 @@ private bool SetPropertyAndNotifyOnCompletion<TTask>(ITaskNotifier<TTask> taskNo
507
507
// This mirrors the return value of all the other synchronous Set methods as well.
508
508
if ( isAlreadyCompletedOrNull )
509
509
{
510
- callback ( newValue ) ;
510
+ if ( callback is not null )
511
+ {
512
+ callback ( newValue ) ;
513
+ }
511
514
512
515
return true ;
513
516
}
@@ -537,7 +540,10 @@ async void MonitorTask()
537
540
OnPropertyChanged ( propertyName ) ;
538
541
}
539
542
540
- callback ( newValue ) ;
543
+ if ( callback is not null )
544
+ {
545
+ callback ( newValue ) ;
546
+ }
541
547
}
542
548
543
549
MonitorTask ( ) ;
0 commit comments