Beispiel #1
0
 public void BeginCmd(string sCmd, SocketLineHandler lh)
 {
     if (bInUse)
     {
         new Exception("IQFeedPort " + portnumber.ToString() + " is in use with '" + sCmd + "'");
     }
     else
     {
         this.lh   = lh;
         bInUse    = true;
         iqfport   = this;
         this.sCmd = sCmd;
         //Monitor.Enter(qPortCmds);
         lock (qPortCmds.SyncRoot) {
             if (0 == qPortCmds.Count)
             {
                 //Console.WriteLine("BeginCmd creating new socket");
                 bs = new BufferedSocket("127.0.0.1", portnumber, lh);
                 bs.Open();
             }
             else
             {
                 //Console.WriteLine("BeginCmd regurgitating socket");
                 bs = qPortCmds.Dequeue() as BufferedSocket;
                 bs.Add(lh);
             }
         }
         //Monitor.Exit(qPortCmds);
         bs.Send(sCmd);
     }
 }
Beispiel #2
0
 public void EndCmd()
 {
     // called externally only if !ENDMSG! is handled externally
     bs.Remove(new Buffer.LineHandler(IgnoreRemainingLines));
     sCmd   = null;
     bInUse = false;
     Monitor.Enter(qPortCmds);
     //Console.WriteLine("enqueing old 9100cmd");
     qPortCmds.Enqueue(bs);
     Monitor.Exit(qPortCmds);
     port = null; //let our selves be released
 }