title: .Net: Retrieving data from threads
body: <p>This is an Easy Q, but great help:</p>
  
  <p>Under title" <em>Retrieving data from threads</em> MSDN (<a href="http://msdn.microsoft.com/en-us/library/ts553s52(VS.71).aspx" rel="nofollow noreferrer">Here</a>) introduces a way to get data from a child thread by using callback method which is encapsulated by a delegate passed from main thread to the child thread - who has the data.</p>
  
  <p>You can see that clearly ( the last Example in the MSDN <a href="http://msdn.microsoft.com/en-us/library/ts553s52(VS.71).aspx" rel="nofollow noreferrer">page</a>)</p>
  
  <p>My Q is, since we are taking about retrieving data  (from child threads to main thread) the call back method should be executed by the main thread and not by the child thread...</p>
  
  <p>I changed the code a bit ( to verify that) so I attached the name of the thread before each output:</p>
  
  <pre><code> public static void ResultCallback(int lineCount) {
      Console.WriteLine(Thread.CurrentThread.Name + ":Independent task printed {0} lines.", lineCount);  
  }
  </code></pre>
  
  <p>And I named the child thread: "Method2" while the main thread "System"...</p>
  
  <p>I got this output: <strong>Method2</strong>: Independent task printed 1 lines. </p>
  
  <p>where the correct output should have been : <strong>System</strong>:Independent task printed 1 lines..</p>
  
  <p>Who is drunk here?  MSDN, me or .NET?</p>