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


C# SendOptions.DelayDeliveryWith方法代码示例

本文整理汇总了C#中SendOptions.DelayDeliveryWith方法的典型用法代码示例。如果您正苦于以下问题:C# SendOptions.DelayDeliveryWith方法的具体用法?C# SendOptions.DelayDeliveryWith怎么用?C# SendOptions.DelayDeliveryWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SendOptions的用法示例。


在下文中一共展示了SendOptions.DelayDeliveryWith方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDeliveryDelay_Should_Return_The_Configured_Delay_TimeSpan

        public void GetDeliveryDelay_Should_Return_The_Configured_Delay_TimeSpan()
        {
            var options = new SendOptions();
            var delay = TimeSpan.FromMinutes(42);
            options.DelayDeliveryWith(delay);

            Assert.AreEqual(delay, options.GetDeliveryDelay());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:DelayedDeliveryOptionExtensionsTests.cs

示例2: DeferMessage

 static void DeferMessage(IBus bus)
 {
     DeferredMessage message = new DeferredMessage();
     SendOptions sendOptions = new SendOptions();
     sendOptions.RouteToLocalEndpointInstance();
     sendOptions.DelayDeliveryWith(TimeSpan.FromSeconds(10));
     bus.Send(message, sendOptions);
     Console.WriteLine();
     Console.WriteLine("{0} - {1}", DateTime.Now.ToLongTimeString(), "Sent a message that is deferred for 10 seconds");
 }
开发者ID:RichieYang,项目名称:docs.particular.net,代码行数:10,代码来源:CommandSender.cs

示例3: DeferTask

        static Task DeferTask(TaskDefinition taskDefinition, IPipelineContext context)
        {
            var options = new SendOptions();

            options.DelayDeliveryWith(taskDefinition.Every);
            options.RouteToThisEndpoint();

            return context.Send(new ScheduledTask
            {
                TaskId = taskDefinition.Id,
                Name = taskDefinition.Name,
                Every = taskDefinition.Every
            }, options);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:14,代码来源:DefaultScheduler.cs

示例4: SendOrder

    static async Task SendOrder(IEndpointInstance endpointInstance)
    {

        Console.WriteLine("Press '1' to send PlaceOrder - defer message handling");
        Console.WriteLine("Press '2' to send PlaceDelayedOrder - defer message delivery");
        Console.WriteLine("Press enter key to exit");

        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();
            Guid id = Guid.NewGuid();

            switch (key.Key)
            {
                case ConsoleKey.D1:
                    #region SendOrder
                    PlaceOrder placeOrder = new PlaceOrder
                    {
                        Product = "New shoes",
                        Id = id
                    };
                    await endpointInstance.Send("Samples.DelayedDelivery.Server", placeOrder);
                    Console.WriteLine("[Defer Message Handling] Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
                    #endregion
                    continue;
                case ConsoleKey.D2:
                    #region DeferOrder
                    PlaceDelayedOrder placeDelayedOrder = new PlaceDelayedOrder
                    {
                        Product = "New shoes",
                        Id = id
                    };
                    SendOptions options = new SendOptions();

                    options.SetDestination("Samples.DelayedDelivery.Server");
                    options.DelayDeliveryWith(TimeSpan.FromSeconds(5));
                    await endpointInstance.Send(placeDelayedOrder, options);
                    Console.WriteLine("[Defer Message Delivery] Deferred a new PlaceDelayedOrder message with id: {0}", id.ToString("N"));
                    #endregion
                    continue;
                case ConsoleKey.Enter:
                    return;
                default:
                    return;
            }
        }

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

示例5: SendDelayedMessage

        public async Task SendDelayedMessage()
        {
            IBusSession busSession = null;
            IMessageHandlerContext handlerContext = null;

            #region delayed-delivery-timespan
            SendOptions options = new SendOptions();
            
            options.DelayDeliveryWith(TimeSpan.FromMinutes(30));

            await handlerContext.Send(new MessageToBeSentLater(), options);
            // OR
            await busSession.Send(new MessageToBeSentLater(), options);
            #endregion
        }
开发者ID:Diedzz,项目名称:docs.particular.net,代码行数:15,代码来源:DeferForTimeSpan.cs

示例6: SendDelayedMessage

        async Task SendDelayedMessage(EndpointConfiguration endpointConfiguration, IEndpointInstance endpoint, IMessageHandlerContext handlerContext)
        {
            #region configure-persistence-timeout

            endpointConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();

            #endregion

            #region delayed-delivery-timespan

            SendOptions options = new SendOptions();

            options.DelayDeliveryWith(TimeSpan.FromMinutes(30));

            await handlerContext.Send(new MessageToBeSentLater(), options);
            // OR
            await endpoint.Send(new MessageToBeSentLater(), options);

            #endregion
        }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:20,代码来源:DeferForTimeSpan.cs

示例7: DelayedDelivery

        async Task DelayedDelivery(IMessageHandlerContext handlerContext, object message)
        {
            #region 5to6delayed-delivery

            SendOptions sendOptions = new SendOptions();
            sendOptions.DelayDeliveryWith(TimeSpan.FromMinutes(30));
            //OR
            sendOptions.DoNotDeliverBefore(new DateTime(2016, 12, 25));

            await handlerContext.Send(message, sendOptions);

            #endregion
        }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:13,代码来源:Upgrade.cs

示例8: Schedule

        static Task Schedule(IMessageSession session, TaskDefinition taskDefinition)
        {
            logger.DebugFormat("Task '{0}' (with id {1}) scheduled with timeSpan {2}", taskDefinition.Name, taskDefinition.Id, taskDefinition.Every);

            var options = new SendOptions();
            options.DelayDeliveryWith(taskDefinition.Every);
            options.RouteToThisEndpoint();
            options.Context.GetOrCreate<ScheduleBehavior.State>().TaskDefinition = taskDefinition;

            var scheduledTask = new ScheduledTask
            {
                TaskId = taskDefinition.Id,
                Name = taskDefinition.Name,
                Every = taskDefinition.Every
            };
            return session.Send(scheduledTask, options);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:17,代码来源:ScheduleExtensions.cs


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