/// <summary>
 /// Adds the listener. If it is not present, executes the visitor operation on the added listener.
 /// </summary>
 public virtual void addListener(T listener, Visitor <T> visitor)
 {
     lock (this)
     {
         bool isNew = listeners.Add(listener);
         if (isNew)
         {
             eventThread.queue(() =>
             {
                 visitor.visit(listener);
             });
         }
     }
 }