title: Auto Close Message Box
body: <p>I have this program wherein I use timer to redirect to another page. It do work but the problem is when I click cancel button a messagebox will appear and when the user will not click on it and the timer ticks, messagebox didn't close. How can I automatically close the message box??</p>
  
  <p>this is what it looks like..</p>
  
  <p><img src="https://i.stack.imgur.com/p6yFS.png" alt="enter image description here"></p>
  
  <p>and here is the code I used to redirect the page</p>
  
  <pre><code> DispatcherTimer sessionTimer = new DispatcherTimer();
      public CashDepositAccount()
      {
          InitializeComponent();
          con = new SqlConnection(ConfigurationManager.ConnectionStrings["kiosk_dbConnectionString1"].ConnectionString);
          con.Open();
          SqlCommand cmd1 = new SqlCommand("Select idle From [dbo].[Idle]", con);
          idle = Convert.ToInt32(cmd1.ExecuteScalar());
  
          InputManager.Current.PreProcessInput += Activity;
          activityTimer = new DispatcherTimer
          {
              Interval = TimeSpan.FromMinutes(idle),
              IsEnabled = true
          };
          activityTimer.Tick += Inactivity;
  
      }
      #region
  
      void Inactivity(object sender, EventArgs e)
      {
  
          navigate = "Home";
          Application.Current.Properties["navigate"] = navigate;
  
      }
  
      void Activity(object sender, PreProcessInputEventArgs e)
      {
  
  
          activityTimer.Stop();
          activityTimer.Start();
  
  
      }
  </code></pre>
  
  <p>How can I close the message box when I redirect to the main page when Timer ticks?</p>