示例#1
0
        /// <summary>
        /// Adds the event that is fired when a window broadcasts on this channel
        /// </summary>
        /// <param name="listener"></param>
        /// <returns></returns>
        public Task AddContextListenerAsync(Action <ContextBase> listener)
        {
            var channelContextListener = new ChannelContextListener
            {
                Channel = this,
                Handler = listener
            };

            var hasAny = FDC3Handlers.HasContextListener(this.ChannelId);

            FDC3Handlers.ChannelContextHandlers.Add(channelContextListener);

            if (!hasAny)
            {
                return(connection.AddChannelContextListenerAsync(this.ChannelId));
            }
            else
            {
                return(new TaskCompletionSource <object>(null).Task);
            }
        }
示例#2
0
 /// <summary>
 /// Removes the event fired when a window
 /// </summary>
 /// <param name="listener"></param>
 public void RemoveContextListener(ChannelContextListener listener)
 {
     FDC3Handlers.ChannelContextHandlers.RemoveAll(x => x.Channel.ChannelId == listener.Channel.ChannelId);
     connection.RemoveChannelContextListenerAsync(listener);
 }