title: How to run a timer in C# only once?
body: <p>I want a timer in C# to destroy itself once it has executed. How might I achieve this?</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      ExecuteIn(2000, () =&gt;
      {
          MessageBox.Show("fsdfs");   
      });           
  }
  
  public static void ExecuteIn(int milliseconds, Action action)
  {
      var timer = new System.Windows.Forms.Timer();
      timer.Tick += (s, e) =&gt; { action(); };
      timer.Interval = milliseconds;
      timer.Start();
  
      //timer.Stop();
  }
  </code></pre>
  
  <p>I want this message box to show only once.</p>