// Close connection when things have gone wrong...
 void  close()
 {
     // System.out.println("Closing Connection...");
     try {
         sendTime = -1L;
         if (output != null)
         {
             output.close();
             output = null;
         }
         if (input != null)
         {
             input.Close();
             input = null;
         }
         if (connection != null)
         {
             connection.Close();
             connection = null;
         }
     } catch (Exception e) {
         if (PrologSession.debugging())
         {
             PrologSession.WriteStackTrace(e, Console.Error);
         }
     }
 }
        PBTerm sendAtom(string commandName, string argument)
        {
            lock (this) {
                if (parentSession != null)
                {
                    return(parentSession.sendAtom(commandName, argument));
                }

                try {
                    initSend();

                    // Write a fastrw term
                    output.writeCompound(commandName, 1);
                    output.writeAtom(argument);
                    output.commit();
                    return(parser.parseProlog(input));
                } catch (System.IO.IOException e) {
                    if (PrologSession.debugging())
                    {
                        PrologSession.WriteStackTrace(e, Console.Error);
                    }
                    close();
                    return(null);
                } finally {
                    finishSend();
                }
            }
        }
Exemple #3
0
        public void  Run()
        {
            do
            {
                try {
                    Thread.Sleep(oneSecond);

                    checkQueries();
                } catch (Exception e) {
                    if (PrologSession.debugging())
                    {
                        Console.Error.WriteLine("PBMonitor: monitor caught an exception:");
                        PrologSession.WriteStackTrace(e, Console.Error);
                    }
                }
            } while (true);
        }