Example #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);
            }
        }