Example #1
0
 /// <summary>
 /// 定型処理になりそうだったので静的メソッドでチャネル生成。
 /// </summary>
 /// <typeparam name="TMessage"></typeparam>
 /// <param name="receiver"></param>
 /// <param name="executor">チャネルを使って、メッセージを送り出す非同期メソッド。</param>
 public static void Execute <TMessage>(this CancellableReceiver <TMessage> receiver, Func <CancellableReceiver <TMessage>, Task> executor)
 {
     receiver.Receiver.SetCompletion(executor(receiver));
 }
Example #2
0
 /// <summary>
 /// <see cref="CancellableReceiver{TMessage}"/>
 /// <see cref="ReceiverExtensions.SendAsync{TMessageBase, TMessage}(IReceiver{TMessageBase}, IEnumerable{TMessage}, CancellationToken)"/>
 /// </summary>
 public static Task <IEnumerable <TMessage> > SendAsync <TMessageBase, TMessage>(this CancellableReceiver <TMessageBase> reciever, TMessage[] messages)
     where TMessage : TMessageBase
 => SendAsync(reciever, (IEnumerable <TMessage>)messages);
Example #3
0
 /// <summary>
 /// <see cref="CancellableReceiver{TMessage}"/>
 /// <see cref="ReceiverExtensions.SendAsync{TMessageBase, TMessage}(IReceiver{TMessageBase}, IEnumerable{TMessage}, CancellationToken)"/>
 /// </summary>
 public static Task <IEnumerable <TMessage> > SendAsync <TMessageBase, TMessage>(this CancellableReceiver <TMessageBase> reciever, IEnumerable <TMessage> messages)
     where TMessage : TMessageBase
 => reciever.Receiver.SendAsync(messages, reciever.CancellationToken);
Example #4
0
 /// <summary>
 /// <see cref="CancellableReceiver{TMessage}"/>
 /// <see cref="ReceiverExtensions.SendAsync{TMessageBase, TMessage}(IReceiver{TMessageBase}, TMessage, CancellationToken)"/>
 /// </summary>
 public static Task <TMessage> SendAsync <TMessageBase, TMessage>(this CancellableReceiver <TMessageBase> reciever, TMessage message)
     where TMessage : TMessageBase
 => reciever.Receiver.SendAsync(message, reciever.CancellationToken);