title: How to stop backgroundworker on page refresh or page close in mvc5?
body: <p>I have an MVC5 application which has Excel upload which will get huge data from excel and save it into database using EF. I am using backgroundworker to upload and get progress. when user clicks some other link or page refresh in the middle of the fileupload and if he upload someother file, the previous progress showing in middle of new upload. I mean the previous process is not killing. How to solve this issue?</p>
  
  <pre><code>bwProcess = new BackgroundWorker{ WorkerReportsProgress = true, WorkerSupportsCancellation = true };
  bwProcess.DoWork += new DoWorkEventHandler(bwProcess_DoWork);
  bwProcess.ProgressChanged += new ProgressChangedEventHandler(bwProcess_ProgressChanged);
  bwProcess.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwProcess_RunWorkerCompleted)‌​;
  Task.Run(() =&gt; bwProcess.RunWorkerAsync("AsyncWorker2"));
  </code></pre>