예제 #1
0
 public CallConcurrentThread(Callback cback, CallbackCommand cmd)
 {
     this.cback = cback;
     this.cmd = cmd;
 }
예제 #2
0
        public void run()
        {
            bool running = true;
            Thread.CurrentThread.Name = "ResponseThread";
            while(running)
            {
                try
                {
                    string buffer = reader.ReadLine();
                    if(!buffer.Trim().Equals(string.Empty))
                    {
                        if (buffer == null)
                        {
                            running = false;
                        }
                    }

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(buffer);
                    XmlElement root = doc.DocumentElement;
                    if(root.Name.Equals("response"))
                    {
                        lastEvent = new TSResponse(root);
                    }
                    else if (root.Name.Equals("callback"))
                    {
                        CallbackCommand cbCommand = new CallbackCommand(root);
                        Callback cback = seqToCallback[cbCommand.SequenceNumber];
                        if(callbackUseThread[cback])
                        {
                            CallConcurrentThread cct = new CallConcurrentThread(cback, cbCommand);
                            new Thread(new ThreadStart(cct.Run)).Start();
                        }
                        else
                        {
                            Call(cback, cbCommand);
                        }
                    }
            //                    Monitor.Enter(mutex);
                    autoResetEvent.Set();
            //                    Monitor.Exit(mutex);
                }
                catch (System.Exception e)
                {
                    Console.Out.WriteLine(e.StackTrace);
                    running = false;
                }
            }
        }
예제 #3
0
 protected void Call(Callback cback, CallbackCommand cmd)
 {
     cback.Call(cmd.Command, 0, cmd.AfterCmd, cmd.BeforeCmd, false);
 }