title: App breaks when using Dispose() method, even though the same code works in different event
body: <p>Few days ago I've started working on my own photo viewer/editor. I've implemented method "OnKeyDown" which changes photos depending of which arrow key is pressed:</p>
  
  <pre><code>case Keys.Left:
              case Keys.Down:
                  ic.getImage().Dispose();
                  --fileIndex;
                  if (fileIndex &lt; 0)
                      fileIndex = (fileCount - 1);
                  ic.setImage(Image.FromFile(fileNames[fileIndex]), ref pictureBox1);
              break;
  
              case Keys.Right:
              case Keys.Up:
                  ic.getImage().Dispose();
                  ++fileIndex;
                  fileIndex %= fileCount;
                  ic.setImage(Image.FromFile(fileNames[fileIndex]), ref pictureBox1);
              break;
  </code></pre>
  
  <p>This works perfectly. Next thing I wanted to do is to program the slideshow, so I used System.Timers.Timer to trigger the event goRight() which executes the same code as if right arrow key is pressed:</p>
  
  <pre><code>public void goRight(object source, ElapsedEventArgs e)
      {
              ic.getImage().Dispose();
              ++fileIndex;
              fileIndex %= fileCount;
              ic.setImage(Image.FromFile(fileNames[fileIndex]), ref pictureBox1);
      }
  </code></pre>
  
  <p>When using slideshow app just breaks. I can't figure out why, because the code is exactly the same. If I comment out the ic.getImage().Dispose() slideshow works but the amount of data in RAM goes higher and higher with each next photo.</p>
  
  <p>Am I doing something wrong? Thank you for your time, I appreciate it!</p>
  
  <p>Uh, I almost forgot. Is there a way to make indexes go backwards without if statement (in key down and key left events) (like operator % for forwards). I did try this:</p>
  
  <pre><code>++fileIndex;
  fileIndex %= fileCount;
  ic.setImage(Image.FromFile(fileNames[(fileCount -1) - fileIndex]), ref pictureBox1);
  </code></pre>
  
  <p>And it works well if I go in just one direction, but if I change direction it skips few indexes. Any thoughts about that?</p>
  
  <p>Best regards. Z</p>