Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 995133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:40:31+00:00 2026-05-16T06:40:31+00:00

I am calling CreateThread from a delphi application and it seems to work, however

  • 0

I am calling CreateThread from a delphi application and it seems to work, however I get a system error: code 1400, invalid window handle.

the code is as follow:

procedure TForm1.SyncFile;
var
  thr: THandle;
  thrID: DWORD;
begin
  thr := CreateThread(nil, 0, @sync, nil, 0, thrID);
  if (thr = 0) then
    ShowMessage('Error creating thread');
end;

procedure sync;
begin
   Connect;
   Application.ProcessMessages;
   SyncText;
   Disconnect;
   ExitThread(0);
end;

I tried with TerminateThread() in form1.syncfile but nop. Also tried with CloseHandle(thr) but no solution here either. I tried then the Delphi TThread but no solution.

What am I doing wrong? Code is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:40:32+00:00Added an answer on May 16, 2026 at 6:40 am

    You shouldn’t perform operations which work against a TForm (or call Application.ProcessMessages) in any thread except the main, GUI thread. The windows message pump expects all windowing operations to be done on the thread that creates the window, and no other thread.

    Try to push your “work” into background threads, but leave the GUI calls on the main thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While calling from my Web Application, WCF response i am getting is : <s:Envelope
When calling rdma_disconnect(), do I get completion queue events for all posted recv work
Calling this powershell command and getting an error. Driving me nuts. Prompt> get-childitem -recurse
Calling the WriteObject Method from a background thread is not possible! Is there a
Calling Html.RenderPartial(~/Views/Payments/MyControl.ascx); from a view works if MyControl.ascx is a control that directly inherits
Calling urrlib2.urlopen on a link to an article fetched from an RSS feed leads
Am calling a webservice from my jQuery to fetch both Staff and Student details.
Calling Index view is giving me this very very annoying error . Can anybody
Calling a .net SOAP1.1 web service from android using ksoap2 lib I met a
Calling uploader.start() before any files are selected results in error in plupload. For example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.