Error : Abnormal termination

 

Hi, i recently wrote 2 complementary EA in order to get familiar with NamePipe.

One EA send data and the other one receive.

The transfert i made accross platform.
SENDER EA is on one plateform and RECEVER EA is on an other platform.
Both MT5

1. Each time i delete the SENDER EA from the chart, it take really long AND at the end i got a error message on the expert tab that say "abnormal termination".
Why does it take that long ? And why do i recevice an error.

2. For the recever EA its quite the same. When i try to delete it from the chart it take way too time. But here i dont get error
Again why does it take that long

The code is below and the inclue file is attached .

Thanks.

Beside that if you have advice to better my code let meknow to.

Thansk again !

// SENDER EA
//--------------------------+ INCLUDE FILE
#include <CNamedPipesFixed.mqh>
         CNamedPipe pipe;
//---------------------------+ CRITICAL VARIABLE
string CommaSpace = ", ";

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetMillisecondTimer(10);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   pipe.Disconnect();
   
  }

//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   while (!pipe.Open(1))
   Sleep(5000);
   
   Print("connected");
   
   while(true)
     {
       for(int i=PositionsTotal()-1;i>=0;i--)    
         {
            if(PositionGetTicket(i) == 0) continue;
            if(PositionGetInteger(POSITION_TYPE) > 1  ) continue;
            if(PositionGetString(POSITION_SYMBOL) !=  ChartSymbol(0)) continue;
            
            long ticket = PositionGetInteger(POSITION_TICKET);
            long type = PositionGetInteger(POSITION_TYPE) ;
            double lot = PositionGetDouble(POSITION_VOLUME);
            string com = PositionGetString(POSITION_COMMENT);
            double PL = PositionGetDouble(POSITION_PROFIT);
            
            string message = (string)ticket + CommaSpace + (string)type + CommaSpace +
                              (string)lot + CommaSpace + com + CommaSpace + (string)PL;
            pipe.WriteANSI(message);
         }
      //pipe.Disconnect();
      //if(!pipe.Open())break                   
     }
  }
//+------------------------------------------------------------------+
//RECEVER EA

#include <CNamedPipesFixed.mqh>
CNamedPipe pipe;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetMillisecondTimer(10);
   while(pipe.Create(1)==false)
      {Print("Pipe creation failed");
       Sleep(1000);}
   Print("Pipe creation succed");
   Print("Waiting for client to connect.");
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   pipe.Disconnect();
   pipe.Close();
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
    if (pipe.Connect()==true) Print("client is connected");
    while(true)
     {
      static string Message ;
      static string Prevread = " ";
      
      Message = pipe.ReadANSI();
      if(Message == Prevread)continue;
      else Print(Message);
      
      Prevread = Message;
     }                        
  }
//+------------------------------------------------------------------+


Files:
 

Infinite loop in your code (Sender).