Question: I am showing a content dialog on one of my sessionstateaware pages, I close the dialog fine and can reopen another on the same page as many times as I want. When I navigate away and come back and try to reopen my dialog, it blows up with this error:

> 
> WinRT information: Only a single ContentDialog can be open at any time.
>  Additional information: An async operation was not properly started.
> 
> 
> 

I have tried numerous things, but it seems whenever I navigate away and come back, somehow the reference to the control is lost and another gets created?

Here is a little snippet of the problem area:

```
if(asyncCommand != null)
asyncCommand.Cancel();

var result = new ContentDialogResult();
if (CanOpenNewDialog)
{

    CanOpenNewDialog = false;
    MyContentDialog.Title = "Homebuyer Options - " + apt.Customer1FullName;
    asyncCommand = MyContentDialog.ShowAsync();

    result = await asyncCommand.AsTask();
}

```

Answer: 
I was curious about the performance of each of the solutions here. Please be welcome to edit this post with your own results, if you like. 

In my tests, the difference between the approaches raised with the length of the list of arrays, so I preferably measured a long list of relatively short arrays. I always did a few runs to remove the possible influence of GC.

```
require 'benchmark'

n = 10
n_arrays = 1000000
arrays = [(1..n).to_a] * n_arrays

Benchmark.bm(14) do |bm|
  bm.report("1st vs others:") do
    array0 = arrays.first
    arrays[1..-1].all? { |a| array0 == a }
  end

  bm.report("uniq:") { arrays.uniq.size == 1 }
  bm.report("each_cons:") { arrays.each_cons(2).all?{|x, y| x == y}  }
end

```

The results suggest that while the `each_cons` approach is about the same (only slightly slower) than the "1st vs others" approach, the one using `uniq` is much much slower.

```
                  user     system      total        real
1st vs others:   0.080000   0.000000   0.080000 (  0.080872)
uniq:            1.810000   0.000000   1.810000 (  1.807646)
each_cons:       0.180000   0.000000   0.180000 (  0.174251)

```
```
array.each_cons(2).all?{|x, y| x == y}

```