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

  • Home
  • SEARCH
  • 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 8585109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:58:47+00:00 2026-06-11T21:58:47+00:00

I have a model object that runs long operations. I’m trying to run some

  • 0

I have a model object that runs long operations. I’m trying to run some of these operations in threads to keep the interface responsive, download 2 things at once, etc, but I want to hide these details from the interface code as much as possible. I’m trying to use the AsyncCall library, but having issues.

type EUpdaterAction = (auFoundCurrentVersion, auFoundUpdateVersion);

type
  TUpdater = class
  public
    procedure loadCurrentVersion();
    procedure notify(action: EUpdaterAction);
  end;

procedure TUpdater.loadCurrentVersion();
begin
  TAsyncCalls.Invoke(procedure 
  begin 
    Assert(Windows.GetCurrentThreadId() <> System.MainThreadID);
    //Really long code
    TAsyncCalls.VCLSync(procedure begin notify(auFoundCurrentVersion); end);
  end);
end;

The assertion fails. Do I need to do something to make it run in a separate thread, or does the first example shown with the library just not actually run in threads?

  • 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-11T21:58:48+00:00Added an answer on June 11, 2026 at 9:58 pm

    You need to call IAsyncCall.ForceDifferentThread to force the code to run in a different thread. In your example the interface that TAsyncCalls.Invoke() returns is released immediately because the function ends and releasing the IAsyncCall interface calls the Sync method. And because your task hasn’t started yet, the Syncmethod will execute it in the same thread, unless the ForceDifferentThread method was called.

    TAsyncCalls.Invoke(procedure 
    begin 
      Assert(Windows.GetCurrentThreadId() <> System.MainThreadID);
      //Really long code
      TAsyncCalls.VCLSync(procedure begin notify(auFoundCurrentVersion); end);
    end).ForceDifferentThread; // <<<<<
    

    But is that really what you want? I guess you want to keep the thread alive after loadCurrentVersion() has exited. And for this AsyncCalls isn’t the right tool.

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

Sidebar

Related Questions

Okay here is what I'm trying to do: I have a model object that
Let's say I have some model objects that resemble this: public class FooModel {
I have a data model object User . My app also has some other
I have a model object that's in fact an enum with fields and getters:
Does jquery/javascript have any event model that you can attach to your objects? Basically
Say I have a model object 'Person' defined, which has a field called 'Name'.
In my application, we have a view model object from which we're retrieving its
I have a page based on a model object, and I want to have
Hi I'm have an object model with an Employee and EmployeeWorksiteReference (cause it's an
I have a parent-child view model object structure set up and need to update

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.