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); } }
/// <summary> /// Peeks at the queue of received events /// </summary> /// <param name="timeout">Time to wait on event arriving if all events have been delivered</param> /// <returns>Event at the front of the queue</returns> public override Event peek(int timeout) { Event evt; checkClosed(); checkNotConnected(); try { evt = (Event)mq.peek(timeout); return(evt); } catch (QueueClosedException queue_closed) { if (Trace.trace) { Trace.error("GroupChannel.peek()", "exception: " + queue_closed); } return(null); } catch (Exception e) { if (Trace.trace) { Trace.error("GroupChannel.peek()", "exception: " + e); } return(null); } }