title: stopping a function executed on a winform button click
body: <ol>
  <li><p>In a simple winform application, I call a function that endlessy create files on a button click event. I add Application.DoEvents() to the loop.</p></li>
  <li><p>I press the red X to close the form.</p></li>
  <li><p>the form closes, but files continue to be created ... </p></li>
  </ol>
  
  <p>I think its on the buttons thread, but shouldnt it be a background one ? trying changing Thread.CurrentThread.IsBackGround to True on the loop function does not help.</p>
  
  <p>Ideas ?</p>