Exemplo n.º 1
0
        // -=-=-=-=-=-=-=- Private Methods -=-=-=-=-=-=-=-=-=-=-=-

        /// <remarks>
        /// This method does the folloing things
        /// 1. Calls <code>this.disconnect</code> if the disconnect parameter is true
        /// 2. Calls <code>Queue.close</code> on mq if the close_mq parameter is true
        /// 3. Calls <code>ProtocolStack.stop</code> on the protocol stack
        /// 4. Calls <code>ProtocolStack.destroy</code> on the protocol stack
        /// 5. Sets the channel closed and channel connected flags to true and false
        /// 6. Notifies any channel listener of the channel close operation
        /// </remarks>
        /// <summary>
        /// Disconnects and closes the channel.
        /// </summary>
        /// <param name="disconnect"></param>
        /// <param name="close_mq"></param>
        private void close(bool disconnect, bool close_mq)
        {
            if (closed)
            {
                return;
            }

            if (disconnect)
            {
                this.disconnect();                                     // leave group if connected
            }
            if (close_mq)
            {
                try
                {
                    mq.close();                                  // closes and removes all messages
                }
                catch (Exception e)
                {
                    if (Trace.trace)
                    {
                        Trace.error("GroupChannel._close()", "exception: " + e);
                    }
                }
            }

            if (prot_stack != null)
            {
                try
                {
                    if (!disconnect)
                    {
                        prot_stack.stop();                         // called in disconnect
                    }
                    prot_stack.destroy();
                }
                catch (Exception e)
                {
                    if (Trace.trace)
                    {
                        Trace.error("GroupChannel._close()", "exception: " + e);
                    }
                }
            }
            closed    = true;
            connected = false;
            if (channel_listener != null)
            {
                channel_listener.channelClosed(this);
            }
        }
Exemplo n.º 2
0
        public void run()
        {
            Console.WriteLine("-=-=-=-=- Add 1 object -=-=-=-=-");
            q.Add(1);

            Console.WriteLine("-=-=-=-=- Peek 5sec -=-=-=-=-");
            Console.WriteLine("Peek: " + q.peek(5000));
            Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
            Console.WriteLine("Remv: " + q.Remove(5000));
            Console.WriteLine("-=-=-=-=- Peek 5sec -=-=-=-=-");
            Console.WriteLine("Peek: " + q.peek(5000));
            Console.WriteLine("-=-=-=-=- Add 1 object -=-=-=-=-");
            q.Add(1);
            Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
            Console.WriteLine("Remv: " + q.Remove(5000));
            Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
            Console.WriteLine("Remv: " + q.Remove(5000));
            Console.WriteLine("-=-=-=-=- Close Queue -=-=-=-=-");
            q.close();
            Console.WriteLine("Closed?: " + q.Closed);

            try
            {
                Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
                Console.WriteLine("Remv: " + q.Remove());
            }
            catch (Exception e)
            {
                Console.WriteLine("-=-=-=-=- Exception Thrown -=-=-=-=-");
                Console.WriteLine("Exception: " + e.Message);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Stops the Up and Down Handler threads
 /// </summary>
 public void stopInternal()
 {
     up_queue.close();              // this should terminate up_handler thread
     down_queue.close();            // this should terminate down_handler thread
 }