title: Launching a Viewmodel inside a Timer elapsed not working
body: <p>I am trying to launch another view model inside a timer event. When I skipped this timer event, it seems that the launcher is being used fine. However, if the launch is done during within the event it doesn't. Can someone please see where the problem is?</p>
  
  <pre><code>using System.Timers;
  using Caliburn.Micro.Xamarin.Forms;
  using MyProject.Resources;
  using System.Windows.Input;
  using Xamarin.Forms;
  using System.Diagnostics;
  
  namespace MyProject.ViewModels
  {
      public class PairingDeviceViewModel : BaseScreen {
      public INavigationService NavigationService { get; set; }
  
      private Timer timer;
      private const float MAX = 20;
      private string percentage;
      private float rate;
  
      public float Rate { get =&gt; rate; set =&gt; Set(ref rate, value); }
      public string Percentage { get =&gt; percentage; set =&gt; Set(ref percentage, value); }
  
  
      protected override void OnInitialize()
      {
          base.OnInitialize();
  
          timer = new Timer
          {
              Interval = MAX,
          };
      }
  
      protected override void OnActivate()
      {
          base.OnActivate();
          timer.Elapsed += Timer_Elapsed;
          timer.Start();
      }
  
      protected override void OnDeactivate(bool close)
      {
          base.OnDeactivate(close);
          timer.Elapsed -= Timer_Elapsed;
      }
  
      private void Timer_Elapsed(object sender, ElapsedEventArgs e)
      {
          Debug.WriteLine($"Timer_Elapsed");
          Debug.WriteLine($"Rate {Rate}");
          Rate++;
          Percentage = string.Format(StringResources.PercentageNumber, Rate);
          NotifyOfPropertyChange(() =&gt; Percentage);
          if (Rate == MAX)
          {
              timer.Stop();
              Debug.WriteLine($"navigation begins");
              NavigationService.NavigateToViewModelAsync&lt;ConfigurationListViewModel&gt;();
          }
          Debug.WriteLine($"Timer_Elapsed END");
      }
  
      public ICommand SkipBluetoothScanning =&gt; new Command(() =&gt; {
          timer.Stop();
          NavigationService.NavigateToViewModelAsync&lt;ConfigurationListViewModel&gt;();
      });
  }
  </code></pre>
  
  <p>So on my <code>Timer_elapsed</code> method, I am calling the <code>NavigationService.NavigateToViewModelAsync&lt;&gt;..</code> once the <code>Rate</code> is equal to <code>MAX</code>. The problem with this one is that this condition <code>Rate==MAX</code> has been called more than once. </p>
  
  <p>Please see the log file. </p>
  
  <pre><code>Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Timer_Elapsed
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Rate 0
  Timer_Elapsed END
  Timer_Elapsed
  Rate 11
  Timer_Elapsed END
  Timer_Elapsed
  Rate 12
  Timer_Elapsed END
  Timer_Elapsed
  Rate 13
  Timer_Elapsed END
  Timer_Elapsed
  Rate 14
  Timer_Elapsed END
  Timer_Elapsed
  Rate 15
  Timer_Elapsed END
  Timer_Elapsed
  Rate 16
  Timer_Elapsed END
  Timer_Elapsed
  Timer_Elapsed END
  Rate 17
  Timer_Elapsed
  Rate 18
  Timer_Elapsed END
  Timer_Elapsed
  Rate 19
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  navigation begins
  Timer_Elapsed END
  [InputMethodManager] HSIFW - flag : 0 Pid : 6116
  [InputMethodManager] HSIFW - flag : 0 Pid : 6116
  Timer_Elapsed END
  Timer_Elapsed END
  Timer_Elapsed END
  Timer_Elapsed END
  Timer_Elapsed END
  Timer_Elapsed END
  [InputMethodManager] HSIFW - flag : 0 Pid : 6116
  [InputMethodManager] HSIFW - flag : 0 Pid : 6116
  Timer_Elapsed END
  Timer_Elapsed END
  [InputMethodManager] HSIFW - flag : 0 Pid : 6116
  Timer_Elapsed END
  Timer_Elapsed END
  [InputMethodManager] HSIFW - flag : 0 Pid : 6116
  Timer_Elapsed END
  </code></pre>
  
  <p>Is <code>DispatcherTimer</code> a better solution for this or another feature if ever?</p>
  
  <p>Thanks a lot. </p>