Jump to content
Registration disabled at the moment Read more... ×
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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×