I think this is what OP is trying to avoid since this is an example of synchronous operation... In this example; order#1 is sent to the broker-server and the function waits for a result. Only after confirmation of order#1 and checking the trade context can it proceed to place order#2, which could take seconds.
Yes, the problem is to avoid waiting for reply of the OrderSend function ...
I think this is what OP is trying to avoid since this is an example of synchronous operation... In this example; order#1 is sent to the broker-server and the function waits for a result. Only after confirmation of order#1 and checking the trade context can it proceed to place order#2, which could take seconds.