title: Visual Studio 2015 Debug doesn't work in multithread application
body: <p>In my project I have a heavy part of code that should be executed on a separate thread without blocking UI. When debugger hits the breakpoint inside this code, VS2015 freezes for 5-10 seconds. After that, if I try to continue debug (by pressing Step Over, Step In or Continue), the app goes from paused state to working state, Debugging Tools are ticking, but nothing happens and there's 0% of CPU utilization. If I press Break All then, the "cursor" (don't know the correct term) is shown at <code>Application.Run( new Form1() );</code> in Program.cs where <code>Main()</code> is.</p>
  
  <p>As I'm pretty new to C#, I thought that there was some problem with my approach to multithreading, but apparently it happens whatever I try - using async/await with Tasks, using <code>BackgroundWorker</code> component, or simple <code>new Thread(myFunc).Start()</code>.</p>
  
  <p>Just to be clear.</p>
  
  <ul>
  <li>The code itself works perfectly fine.</li>
  <li>Debugger itself also works, no freezes and "deadlocks" on breakpoints in my main thread. If I launch the code from main thread - everything is fine.</li>
  <li>I also checked it in a fully new solution on a simple <code>for ( int i = 0; i &lt; Int32.MaxValue; ++i )</code> function - same problem.</li>
  <li>Also checked on different versions of .NET: 4.6, 4.5, 4.0. Same everywhere.</li>
  <li>The problem doesn't appear neither in VS2010 (which I used before), nor in VS2013 (which I tried just to be sure that it's a VS2015 problem). <em>However</em>, my friend working with the same VS2015 also doesn't have this problem.</li>
  </ul>
  
  <p><strong>Edit:</strong> per request, code of test form where I keep getting the problem. Only three buttons, label, and BackgroundWorker. The overall scheme is similar to the code of the main project.</p>
  
  <pre><code>    public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      const int period = 10000;
      void FuncAsync(IProgress&lt;int&gt; progress)
      {
          for ( int i = 0; i &lt; Int32.MaxValue; ++i )
          {
              double part = (double)i / Int32.MaxValue;
              int percent = (int)(part * 100.0);
  
              if ( (i % period) == 0 )
                  progress.Report( percent );
          }
      }
      void FuncBW(BackgroundWorker worker)
      {
          for ( int i = 0; i &lt; Int32.MaxValue; ++i )
          {
              double part = (double)i / Int32.MaxValue;
              int percent = (int)(part * 100.0);
  
              if ( (i % period) == 0 )
                  worker.ReportProgress( percent );
          }
      }
      void FuncThread()
      {
          for ( int i = 0; i &lt; Int32.MaxValue; ++i )
          {
              double part = (double)i / Int32.MaxValue;
              int percent = (int)(part * 100.0);
  
              if ( (i % period) == 0 )
                  label1.Text = percent.ToString();
              //yes, this one will cause exception of accessing UI from different thread
              //if i press "Break" in the exception window, i will also get a 10sec freeze
          }
      }
  
  
  
      private async void button1_Click(object sender, EventArgs e)
      {
          var progress = new Progress&lt;int&gt;(i =&gt; label1.Text = i.ToString() );
          await Task.Factory.StartNew( () =&gt; FuncAsync( progress ),
                                      TaskCreationOptions.LongRunning );
      }
  
      private void button2_Click(object sender, EventArgs e)
      {
          backgroundWorker1.RunWorkerAsync();
      }
  
      private void button3_Click(object sender, EventArgs e)
      {
          Thread t = new Thread(FuncThread);
          t.Start();
      }
  
      private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
          FuncBW( (BackgroundWorker)sender );
      }
  
      private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
      {
          label1.Text = e.ProgressPercentage.ToString();
      }
  }
  </code></pre>