title: Delphi TThread.CurrentThread and EAccessViolation - Is This a Bug or My Incompetence..?
body: <p>In Delphi 2009 I'm finding that any time I use TThread.CurrentThread in an application, I'll get an error message like the following when the application closes:</p>
  
  <pre><code>Exception EAccessViolation in module ntdll.dll at 0003DBBA.
  Access violation at address 7799DBBA in module 'ntdll.dll'.  Write of
  address 00000014.
  </code></pre>
  
  <p>Unless it's just my machine, you can replicate this in a few seconds: create a new Delphi Forms Application, add a button to the form, and use something like the following for the button's event handler:</p>
  
  <pre><code>procedure TForm1.Button1Click(Sender: TObject);
  begin
    TThread.CurrentThread;
  end;
  </code></pre>
  
  <p>On both my Vista machine and my XP machine I'm finding that, if I <em>don't</em> click the button everything's fine, but if I <em>do</em> click the button I get the above error message when I close the application.</p>
  
  <p>So...  I'm wondering if this is a bug, but at the same time I think it's rather likely that I'm simply not understanding something very basic about how you're supposed to work with TThreads in Delphi.  I am a bit of a Delphi newbie I'm afraid.</p>
  
  <p>Is there something obviously wrong with using TThread.CurrentThread like that?</p>
  
  <p>If not, and you have Delphi 2009, do you get the same problem if you implement my simple sample project?</p>
  
  <hr>
  
  <h2><strong>Update: As François noted below, this actually is a bug in Delphi 2009 at the moment - you can <a href="http://qc.codegear.com/wc/qcmain.aspx?d=67726" rel="noreferrer">vote for it here</a>.</strong></h2>
  
  <hr>
  
  <h2><strong>Update: This bug was fixed in Delphi 2010.</strong></h2>