Skip to content

Commit

Permalink
Merge pull request #3 from Yinimi/yinimi/mergeAll
Browse files Browse the repository at this point in the history
Yinimi/merge all
  • Loading branch information
Yinimi authored Nov 11, 2024
2 parents af09f9c + 290c651 commit 52a65f3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public AsyncActivationScreen(bool simulateAsyncOnActivate, bool simulateAsyncOnD
_simulateAsyncTaskDuration = simulateAsyncTaskDuration;
}

protected override async Task OnActivateAsync(CancellationToken cancellationToken)
protected override async Task OnActivatedAsync(CancellationToken cancellationToken)
{
await base.OnActivateAsync(cancellationToken);
await base.OnActivatedAsync(cancellationToken);

if (_simulateAsyncOnActivate)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Micro.Core/Conductor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override async Task DeactivateItemAsync(T item, bool close, CancellationT

if (closeResult.CloseCanOccur)
{
await ChangeActiveItemAsync(default(T), close);
await ChangeActiveItemAsync(default(T), close, cancellationToken);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Caliburn.Micro.Core/ConductorBaseWithActiveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ object IHaveActiveItem.ActiveItem
/// <returns>A task that represents the asynchronous operation.</returns>
protected virtual async Task ChangeActiveItemAsync(T newItem, bool closePrevious, CancellationToken cancellationToken)
{
var previousItem = _activeItem;
newItem = EnsureItem(newItem);

_activeItem = newItem;
NotifyOfPropertyChange(nameof(ActiveItem));

await ScreenExtensions.TryDeactivateAsync(_activeItem, closePrevious, cancellationToken);
await ScreenExtensions.TryDeactivateAsync(previousItem, closePrevious, cancellationToken);

if (IsActive)
await ScreenExtensions.TryActivateAsync(newItem, cancellationToken);
Expand Down
4 changes: 2 additions & 2 deletions src/Caliburn.Micro.Core/ConductorWithCollectionOneActive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private async Task CloseItemCoreAsync(T item, CancellationToken cancellationToke
var index = _items.IndexOf(item);
var next = DetermineNextItemToActivate(_items, index);

await ChangeActiveItemAsync(next, true);
await ChangeActiveItemAsync(next, true, cancellationToken);
}
else
{
Expand Down Expand Up @@ -164,7 +164,7 @@ public override async Task<bool> CanCloseAsync(CancellationToken cancellationTok
} while (closable.Contains(next));

var previousActive = ActiveItem;
await ChangeActiveItemAsync(next, true);
await ChangeActiveItemAsync(next, true, cancellationToken);
_items.Remove(previousActive);

var stillToClose = closable.ToList();
Expand Down
4 changes: 4 additions & 0 deletions src/Caliburn.Micro.Core/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,17 @@ async Task IActivate.ActivateAsync(CancellationToken cancellationToken)

if (!IsInitialized)
{
#pragma warning disable CS0618 // Type or member is obsolete
await OnInitializeAsync(cancellationToken);
#pragma warning restore CS0618 // Type or member is obsolete
IsInitialized = initialized = true;
await OnInitializedAsync(cancellationToken);
}

Log.Info("Activating {0}.", this);
#pragma warning disable CS0618 // Type or member is obsolete
await OnActivateAsync(cancellationToken);
#pragma warning restore CS0618 // Type or member is obsolete
IsActive = true;
await OnActivatedAsync(cancellationToken);

Expand Down

0 comments on commit 52a65f3

Please sign in to comment.