title: Show subtitles in WPF
body: <p>I'm developing an application in which I have a window with a <code>MediaElement</code>. The user can play the movie in this window. I would like to add an option to play the movie with subtitles. I know how to display text over the <code>MediaElement</code> but the problem is, how to display subtitles at certain intervals.</p>
  
  <p>My solution (which doesn't work): I will parse a <code>.src</code> file to a dictionary where <code>Key</code> is <code>start time</code> and <code>value</code> is <code>text</code>.</p>
  
  <p>Next, I have a timer with a 1 ms interval and at each interval I would check if the movie-time exists in the dictionary. If yes, I will show the value. Problem is, that I'm not able to check dictionary every millisecond but the interval is about 20 ms and this is the problem. So do you know how to call it every 1 millisecond?</p>
  
  <pre><code>private void timer_Tick(object sender, EventArgs e)
  {
     string text = MediaElement.Position.ToString("HH:mm:ss.fff");
     Thread t = new Thread(() =&gt; SearchThread(text));
     t.Start();
     if (MediaElement.NaturalDuration.HasTimeSpan)
        timer.Text = String.Format("{0} / {1}", MediaElement.Position,
                     MediaElement.NaturalDuration.TimeSpan.ToString());
  }
  
  private void SearchThread(string pos)
  {
     string text = srcFileControler.Get(pos); //take value from dictionary if exist
     if (text != "")
        this.txtSub.Dispatcher.Invoke(DispatcherPriority.Normal,
             new Action(() =&gt; { txtSub.Text = text; }));  
  }
  </code></pre>