title: Why is threadTerminate not called inside a dll
body: <p>I have a problem that code inside my dll is acting different compared to the same code within a normal application. After some debugging I found that the thread's OnTerminate is never called within the dll. </p>
  
  <pre><code>type
    TTest = class
    private
    public
       procedure threadStart();
       procedure threadEnd(Sender: TObject);
       procedure lines(value: String);
    end;
  
  procedure TTest.threadStart();
  var aThread : TThread;
  begin
   aThread :=
      TThread.CreateAnonymousThread(
        procedure
        begin
           lines('start')
        end
      );
    aThread.FreeOnTerminate := True;
    aThread.OnTerminate := self.threadEnd;
    aThread.Start;
  end;
  
  procedure TTest.threadEnd;
  begin
    lines('end')
  end;
  
  procedure TTest.lines(value: String);
    var MyText: TStringlist;
  begin
    MyText:= TStringlist.create;
    MyText.Add(value);
    MyText.SaveToFile('.\filename.txt');
    MyText.Free
  end;
  </code></pre>
  
  <p>If I run this code from a normal VLC Delphi Application, I get <strong>end</strong> in the text file.
  If I run the same code from a dll (loading it either static or dynamic into a VLC Application), I get <strong>start</strong> in the text file.</p>
  
  <p>My question: Why? Or better asked, how can I let my dll act the same way as my VLC. Current version I'm using is XE7.</p>