title: How to call a method of a TThread object from the main VCL thread?
body: <p>I use Thread in my code to send SMS.
  for Send SMS I use the <code>MCoreComponent</code> Class;
  first, override <code>Create</code> function AND create a <code>objSMS1</code> object,
  then call <code>objSMS1.connect()</code> in the <code>Execute</code> Function</p>
  
  <pre><code>constructor ReceiveThread.create;
  begin
    Inherited Create(True);
    objSMS1 := TSMS.Create(nil);
  end;
  
  procedure ReceiveThread.Execute();
  begin
    if Not objSMS1.IsError(true, strMyAppName) then
    begin
      objSMS1.Connect();
      if Not objSMS1.IsError(true, strMyAppName) then
         ShowMessage('Connection successful');
    end;
  
    while not Terminated do
    begin
      CoInitialize(nil);
      DoShowData;//Recieved Message
    end;
  end;
  </code></pre>
  
  <p>these two functions work correctly, Connecting to Module Successfully Done, and check inbox every time.</p>
  
  <p>But I need to send a message. My <code>Send Message</code> Function Is:</p>
  
  <pre><code>procedure ReceiveThread.SendSMS(phoneno, txt: String);
  var strSendResult :String;
  begin
    objSMS1.Validity := Trim('24') + LeftStr('Hour', 1);//Access    Violation    Error
  
    strSendResult := objSMS1.SendSMS(phoneno, txt, False);
    if Not objSMS1.IsError(true, strMyAppName) then
      MessageDlg('Message sent!', mtInformation, [mbOK], 0);
  end;
  </code></pre>
  
  <p>When I call the <code>SendSMS</code> Function In Button Click On Main Form, App encounter Access Violation Error. How can I Call Send Message In Thread?</p>
  
  <p>other Setting</p>
  
  <pre><code>  var
      RTh : ReceiveThread;//Global Var
  
    //Run Tread
    RTh := ReceiveThread.Create();
    RTh.FreeOnTerminate := True;
  
  
    //Send Message From Button Click
    RTh.SendSMS(Phoneno,Msg);//Access Violation Error
  </code></pre>