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 7979767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:51:48+00:00 2026-06-04T09:51:48+00:00

I have always been displaying such things in the main thread and using events

  • 0

I have always been displaying such things in the main thread and using events to synchronize the end of a window with a thread to let it know when the windows is closed.

Today, during development I wanted to move displayed form from thread to main UI, but it successfully was displayed. The only thing I added is that in the main thread I am pushing messages waiting on the event:

procedure WaitWithMessageLoop();
var
vWaitForEventHandles:array[0..1] of THandle;
vWaitForResponse:DWORD;
Msg: TMSG;
begin
vWaitForEventHandles[0] := LServiceMonitor.Handle;
while (1=1) do
begin
  vWaitForResponse := MsgWaitForMultipleObjects(1, vWaitForEventHandles, FALSE, INFINITE, QS_ALLINPUT);
  if (vWaitForResponse = WAIT_OBJECT_0 + 1) then
  begin
    while (PeekMessage(msg,0,0,0,PM_REMOVE)) do
    begin
      TranslateMessage(msg);
      DispatchMessage(msg);
    end;
  end
  else
  if (vWaitForResponse = WAIT_FAILED)
    then RaiseLastOSError
    else break;
end;
end;

So my question is. Is a such scenerio acceptable? Or Should I move a form to be displayed in the main thread?

Thanks

  • 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-06-04T09:51:49+00:00Added an answer on June 4, 2026 at 9:51 am

    You cannot reliably run VCL forms outside the main GUI thread. When you try to do this, it may appear to work, but at some point in the future such code will fail. Most likely on your most important clients machine, in a particularly critical manner!

    The VCL was designed such that all VCL forms are created and operated on from the main GUI thread only. If you need to invoke VCL forms then you have to use tools like TThread.Synchronize to make sure that the forms are created on the GUI thread.

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

Sidebar

Related Questions

I have always been using virtualenv for testing my app in localhost since I
I have been using this script of mine FOREVER and I have always been
I have always been religiously using SGI's Standard Template Library Programmer's Guide (STLPG) as
I have been using CSS for many years now, and I have always been
I have always been a bit unclear on the type of tasks that should
I have always been kind of confused by threads, and my class right now
I have always been a good boy when writing my classes, prefixing all member
ListViews have always been my weak point and right now I am practicing putting
There has always been a confusion with preg_match in php. I have a string
I have modified a working Windows service that had always been starting beforehand. After

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.