Skip to content

Commit

Permalink
Fix up samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Sampson committed Nov 4, 2018
1 parent a69335b commit 217982f
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Features.CrossPlatform.ViewModels
{
public class TabViewModel : Screen
{
private readonly Random random = new Random();

public TabViewModel()
{
Messages = new BindableCollection<string>();
Expand All @@ -33,6 +35,18 @@ protected override Task OnDeactivateAsync(bool close, CancellationToken cancella
return Task.CompletedTask;
}

public override async Task<bool> CanCloseAsync(CancellationToken cancellationToken)
{
var delay = random.Next(5) + 1;
var canClose = random.Next(2) == 0;

Messages.Add($"Delaying {delay} seconds and allowing close: {canClose}");

await Task.Delay(TimeSpan.FromSeconds(delay));

return canClose;
}

public BindableCollection<string> Messages { get; }
}
}
Loading

0 comments on commit 217982f

Please sign in to comment.