Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Different procedures in OnClick event
#1
Question 
Hello,

I am developing wint Delphi 12.1 Patch 1 and IW 15.6.3.

In an OnClick event of a button I need to execute two different procedures.
The first one save some data to a DB (quick, no problem), the second one call a web service which introduce some delay in response and update of the page.

The procedure is invoked inside a runtime created data module.
Is it possible to use TTask from PPL to execute the web service call asynchronously?

It will be ok to use PPL inside the thread where the data module is executed (considering the multi thread architecture of IW)?

Thank you,
Davide
Reply
#2
Yes, you can use TTask from the Parallel Programming Library (PPL) to execute the web service call asynchronously, even in the context of IntraWeb (IW) applications, which can be multithreaded.
Here's a general approach to achieve this:
Execute the Database Operation Synchronously: Since this operation is quick and doesn't involve waiting for external resources, you can perform it directly in the OnClick event.
Execute the Web Service Call Asynchronously: Use TTask to handle the web service call asynchronously. This way, the UI remains responsive, and you don't block the main thread while waiting for the web service response.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)