当前位置: 首页>>代码示例>>C#>>正文


C# IBus.SendAsync方法代码示例

本文整理汇总了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();
 }
开发者ID:Royal-Jay,项目名称:Zombus,代码行数:12,代码来源:WhenSendingManyCommandsOfDifferentTypes.cs

示例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"));

        }

    }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:29,代码来源:Program.cs

示例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");
 }
开发者ID:marablec,项目名称:docs.particular.net,代码行数:9,代码来源:Program.cs

示例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
    }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:12,代码来源:Program.cs

示例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);
    }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:15,代码来源:Program.cs

示例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");
    }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:16,代码来源:Program.cs

示例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");
    }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:19,代码来源:Program.cs


注:本文中的IBus.SendAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。