本文整理汇总了C#中IBus.SendAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IBus.SendAsync方法的具体用法?C# IBus.SendAsync怎么用?C# IBus.SendAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBus
的用法示例。
在下文中一共展示了IBus.SendAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMessages
public override IEnumerable<Task> SendMessages(IBus bus)
{
for (var i = 0; i < NumMessagesToSend/4; i++)
{
yield return bus.SendAsync(new FooCommand());
yield return bus.SendAsync(new BarCommand());
yield return bus.SendAsync(new BazCommand());
yield return bus.SendAsync(new QuxCommand());
Console.Write(".");
}
Console.WriteLine();
}
示例2: SendOrder
static async Task SendOrder(IBus bus)
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
break;
}
Guid id = Guid.NewGuid();
PlaceOrder placeOrder = new PlaceOrder
{
Product = "New shoes",
Id = id
};
await bus.SendAsync("Samples.StepByStep.Server", placeOrder);
Console.WriteLine("Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
}
}
示例3: SendJsonMessage
static async Task SendJsonMessage(IBus bus)
{
MessageWithJson message = new MessageWithJson
{
SomeProperty = "Some content in a json message",
};
await bus.SendAsync("Samples.MultiSerializer.Receiver", message);
Console.WriteLine("Json Message sent");
}
示例4: SendMessageTooLargePayload
static async Task SendMessageTooLargePayload(IBus bus)
{
#region SendMessageTooLargePayload
AnotherMessageWithLargePayload message = new AnotherMessageWithLargePayload
{
LargeBlob = new byte[1024*1024*5] //5MB
};
await bus.SendAsync("Samples.DataBus.Receiver", message);
#endregion
}
示例5: SendMessageLargePayload
static async Task SendMessageLargePayload(IBus bus)
{
#region SendMessageLargePayload
MessageWithLargePayload message = new MessageWithLargePayload
{
SomeProperty = "This message contains a large blob that will be sent on the data bus",
LargeBlob = new DataBusProperty<byte[]>(new byte[1024*1024*5]) //5MB
};
await bus.SendAsync("Samples.DataBus.Receiver", message);
#endregion
Console.WriteLine("Message sent, the payload is stored in: " + BasePath);
}
示例6: SendMessageWithFileStream
static async Task SendMessageWithFileStream(IBus bus)
{
#region send-message-with-file-stream
MessageWithStream message = new MessageWithStream
{
SomeProperty = "This message contains a stream",
StreamProperty = File.OpenRead("FileToSend.txt")
};
await bus.SendAsync("Samples.PipelineStream.Receiver", message);
#endregion
Console.WriteLine();
Console.WriteLine("Message with file stream sent");
}
示例7: SendMessageWithHttpStream
static async Task SendMessageWithHttpStream(IBus bus)
{
#region send-message-with-http-stream
using (WebClient webClient = new WebClient())
{
MessageWithStream message = new MessageWithStream
{
SomeProperty = "This message contains a stream",
StreamProperty = webClient.OpenRead("http://www.particular.net")
};
await bus.SendAsync("Samples.PipelineStream.Receiver", message);
}
#endregion
Console.WriteLine();
Console.WriteLine("Message with http stream sent");
}