title: How to Dispose VlcControl for wpf
body: <p>I am using Vlc.DotNet.Wpf for playing video</p>
  
  <ol>
  <li>creating VlcControl object</li>
  </ol>
  
  <p>`</p>
  
  <pre><code>private void CreateVlcObject1()
  {
     myControl1 = new VlcControl();
     myControl1.MediaPlayer.VlcLibDirectoryNeeded+=MediaPlayer_VlcLibDirectoryNeeded;
     myControl1.MediaPlayer.EndReached += MediaPlayer_EndReached1;    
     myControl1.MediaPlayer.EndInit(); myControl1.MediaPlayer.Play(newUri(@"C:\Users\Public\videos\45.mp4"));
     MainGrid.Children.Add(myControl1);
  }
  </code></pre>
  
  <p>`</p>
  
  <ol start="2">
  <li>Dispose Method of VlcControl object</li>
  </ol>
  
  <p>`</p>
  
  <pre><code>  private void DisposeObject1()
    {  
      myControl1.MediaPlayer.VlcLibDirectoryNeeded -=   MediaPlayer_VlcLibDirectoryNeeded1;
      myControl1.MediaPlayer.EndReached -= MediaPlayer_EndReached1;
  
  
      if (!myControl1.MediaPlayer.IsDisposed)
      {
         myControl1.MediaPlayer.Stop();                
         myControl1.MediaPlayer.Dispose();
      }
         myControl1 = null;
         MainGrid.Children.Remove(myControl1);
   }
  </code></pre>
  
  <p>`</p>
  
  <p>the program get stuck at stop method in Dispose method however if i comment stop method it will stuck at the dispose method.
  Without Disposing this object i can't proceed further as it eats 100 MB in 1 min.</p>
  
  <p>When I break it shows like this:
  <a href="https://i.stack.imgur.com/sSzOK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sSzOK.png" alt="Break All"></a>
  My Question is how to Dispose this VlcControl object
  <strong>Edited</strong>
  I am disposing vlc object in every 15 seconds</p>