Jump to content
Larry2023

TRESTClient in a Thread

Recommended Posts

I have a function that uses TRESTClient (and associated classes) in an EXE.  The function works great in the EXE.  I am attempting to move that function to a thread in a console app (later this will be a service).

 

I created a new class MyService = class(TThread).   The application flow is:

 

Start console app.

Create MyService

From MyService.Excute call the function (good so far)

In the function:

    Run an ADO query (this works)

    Create the TRESTClient (and associated objects).  These are created dynamically.

    Call the TRESTRequest.Execute method.  In TRESTRequest.Execute the entire application appears to hang.

 

Anyone have any pointers?  Thx!

 

Share this post


Link to post
5 minutes ago, Larry2023 said:

to move that function to a thread in a console app

So you should check this hint in the docs: 

Quote

In a non-GUI application, you must call CheckSynchronize if you use the Synchronize method of TThread.

In case you didn't change The SynchronizedEvents property of the TRESTRequest, it internally calls Synchronize, which forces you to obey the above.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×