ConnectNamedPipe crash mt4 when script are stoped

 

Hi.

I have a script that connect other program with pipe mode.

while(!IsStopped()) {

bool fConnected = ConnectNamedPipe(hPipe, NULL)!= 0;

if (fConnected) {

The lines above are responsable to wait for this connection.

My problem is that When I dont have any connect and I try to exit this script, it crasch the mt4.

How can I to wait for connections and exit without crash mt4?

Thanks and sorry my english

 
Have you tried to put else ? It crashes most probably because there is no alternative commands to do if not connected.
 
deysmacro:
Have you tried to put else ? It crashes most probably because there is no alternative commands to do if not connected.

Thanks deysmacro:h but with this command connectnamedpipe stop the script and wait for a connection so I cant use an else because I need to wait for a connection. For this reason, my script are inside a while for run all function and restart again and wait again for a new connection...
 
Show us full code then. Someone will look into if they have spare time. Use SRC when posting codes.
 
bisewski:

Hi.

I have a script that connect other program with pipe mode.

while(!IsStopped()) {

bool fConnected = ConnectNamedPipe(hPipe, NULL)!= 0;

if (fConnected) {

The lines above are responsable to wait for this connection.

My problem is that When I dont have any connect and I try to exit this script, it crasch the mt4.

How can I to wait for connections and exit without crash mt4?

Thanks and sorry my english

Please post code that makes sense and use SRC button as suggested by deysmacro.
Reason: