I am building a REST client EA. Is it recommended to run Internet queries on the EA's main thread?

To add comments, please log in or register
Jordi Bassaganas
3567
Jordi Bassaganas  

Hello everyone,

I am building a REST client EA which makes HTTP calls to an external web service. I would like to know which is the best and simplest way for the EA to perform the HTTP query and get the JSON data.

From what I have seen in Code Base, coders use to make HTTP calls in the context of the main thread, but I think that it would be better to "fork" the main process, or create a new async thread in order to call the webservice. There sre some OO programming languages ​​with classes to facilitate the creation of these kind of asynchronous threads...

Is there something like that in MQL5? Otherwise, is it recommended to run Internet queries on the EA's main thread?

Thanks in advance,

Alain Verleyen
37992
Alain Verleyen  
laplacianlab:

Hello everyone,

I am building a REST client EA which makes HTTP calls to an external web service. I would like to know which is the best and simplest way for the EA to perform the HTTP query and get the JSON data.

From what I have seen in Code Base, coders use to make HTTP calls in the context of the main thread, but I think that it would be better to "fork" the main process, or create a new async thread in order to call the webservice. There sre some OO programming languages ​​with classes to facilitate the creation of these kind of asynchronous threads...

Is there something like that in MQL5? Otherwise, is it recommended to run Internet queries on the EA's main thread?

Thanks in advance,

There is no facilities in mql5 to manage threads. However with a little imagination you can run code in multiple threads and communicate between them.

The recommended way to communicate with external process is through named pipes.

Jordi Bassaganas
3567
Jordi Bassaganas  
angevoyageur:

There is no facilities in mql5 to manage threads. However with a little imagination you can run code in multiple threads and communicate between them.

The recommended way to communicate with external process is through named pipes.

Thanks for your feedback! For what you say, I understand that it is ok to perform Internet calls on the main thread. I think I can do like that because my robot is medium and long term.
To add comments, please log in or register