示例#1
0
        /// <summary>
        /// Creates a case for sending to the specific channel.
        /// </summary>
        /// <param name="c">The channel to send to. Can be <c>null</c>.</param>
        /// <param name="message">The message to send.</param>
        /// <param name="func">The callback function to execute once the message has been sent. Can be <c>null</c>.</param>
        /// <returns>An instance to append another Case, Default, or NoDefault. Select must end with a call to
        /// Default or NoDefault.</returns>
        public SelectCase CaseSend <T>(ISendOnlyChan <T> c, T message, Action func = null)
        {
            if (_isExecuteCalled)
            {
                throw new Exception("select already executed");
            }

            if (c != null)
            {
                _sendFuncs.Add(
                    new SendCase
                {
                    Chan = c
                }
                    , new Tuple <Action, object>(func, message)
                    );
            }

            return(this);
        }
示例#2
0
 /// <summary>
 /// Creates a case for sending to the specific channel.
 /// </summary>
 /// <param name="c">The channel to send to. Can be <c>null</c>.</param>
 /// <param name="message">The message to send.</param>
 /// <param name="func">The callback function to execute once the message has been sent. Can be <c>null</c>.</param>
 /// <returns>An instance to append another Case, Default, or NoDefault. Select must end with a call to
 /// Default or NoDefault.</returns>
 public static SelectCase CaseSend <T>(ISendOnlyChan <T> c, T message, Action func = null)
 {
     return(new SelectCase().CaseSend(c, message, func));
 }