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


C# Scheduler.Schedule方法代码示例

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


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

示例1: Given_schduler_with_some_work

        public void Given_schduler_with_some_work()
        {
            _scheduler = new Scheduler();

            _scheduler.Schedule("Foo1", () => Console.WriteLine("Foo1"), TimeSpan.FromMinutes(2));
            _scheduler.Schedule("Foo2", () => Console.WriteLine("Foo2"), TimeSpan.FromMinutes(2));
        }
开发者ID:JustApplications,项目名称:inline_scheduler,代码行数:7,代码来源:When_gather_statistics.cs

示例2: Given_scheduler_with_daily_item

        public void Given_scheduler_with_daily_item()
        {
            var context = new TestSchedulerContext();

            _scheduler = new Scheduler(context);

            var runsoon = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            var foo1 = JobFactory.Daily("Foo1", () => { Console.WriteLine("Foo1"); foo1_calls += 1; }, runsoon, description: "Description for Foo1");
            var foo2 = JobFactory.Daily("Foo2", () => Console.WriteLine("Foo2"), runsoon);

            _scheduler.Schedule(foo1);
            _scheduler.Schedule(foo2);

            _scheduler.Start();

            Wait.Until(() => foo1_calls > 0, 30);

            context.MoveToTommorrow();

            Wait.Until(() => foo1_calls > 1, 30);

            context.MoveForwardNDays(2);

            Wait.Until(() => foo1_calls > 2, 50);
        }
开发者ID:JustApplications,项目名称:inline_scheduler,代码行数:26,代码来源:When_schedule_some_daily_work.cs

示例3: Given_scheduler_with_some_work

        public void Given_scheduler_with_some_work()
        {
            var ctx = new TestSchedulerContext();
            _scheduler = new Scheduler(ctx);

            _scheduler.Schedule("Foo1", () => { _foo1WorkDone = true; }, TimeSpan.FromMinutes(10));
            _scheduler.Schedule("Foo2", () => { _foo2WorkDone = true; }, TimeSpan.FromMinutes(10));

            // Lest ensure that all workitems
            // are applicable for schedule
            ctx.MoveToTommorrow();

            _scheduler.Start();

            Wait.Until(() => _scheduler.GatherOveralStats().RunningJobs + _scheduler.GatherOveralStats().ScheduledJobs == 0);
        }
开发者ID:chaliy,项目名称:inline_scheduler,代码行数:16,代码来源:When_do_some_work_items.cs

示例4: Auction

		public Auction(Inbox inbox, Fiber fiber, Scheduler scheduler)
		{
			_currentBid = 1.00m;

			scheduler.Schedule(60000, fiber, () =>
			{
				inbox.Send(new EndAuction());
			});

			inbox.Loop(loop =>
			{
				loop.Receive<Request<AuctionStatus>>(request =>
				{
					request.Respond(new AuctionStatusImpl
					{
						CurrentBid = _currentBid,
						IsOpen = _open,
					});
				});

				loop.Receive<Request<PlaceBid>>(request =>
				{
					if (request.Body.MaximumBid <= _currentBid)
					{
						request.Respond(new OutBidImpl
						{
							CurrentBid = _currentBid
						});
					}
					else
					{
						_currentBid = request.Body.MaximumBid;
						request.Respond(new BidAcceptedImpl
						{
							CurrentBid = _currentBid
						});
						if (_highBidder != null)
						{
							_highBidder.Send(new OutBidImpl
							{
								CurrentBid = _currentBid
							});
						}
						_highBidder = request.ResponseChannel;
					}

					loop.Continue();
				});

				loop.Receive<EndAuction>(msg =>
				{
					_open = false;
//					_highBidder.Send(new YouWin());
				});
			});
		}
开发者ID:Nangal,项目名称:Stact,代码行数:56,代码来源:Auction.cs

示例5: PollingFileSystemEventProducer

        /// <summary>
        /// Creates a PollingFileSystemEventProducer
        /// </summary>		
        /// <param name="directory">The directory to watch</param>
        /// <param name="channel">The channel where events should be sent</param>
        /// <param name="scheduler">Event scheduler</param>
        /// <param name="fiber">Fiber to schedule on</param>
        /// <param name="checkInterval">The maximal time between events or polls on a given file</param>
        /// <param name="checkSubDirectory">Indicates if subdirectorys will be checked or ignored</param>
        public PollingFileSystemEventProducer(string directory, UntypedChannel channel, Scheduler scheduler, Fiber fiber,
            TimeSpan checkInterval, bool checkSubDirectory)
        {
            _directory = directory;
            _channel = channel;
            _fiber = fiber;
            _hashes = new Dictionary<string, Guid>();
            _scheduler = scheduler;
            _checkInterval = checkInterval;

            _scheduledAction = scheduler.Schedule(3.Seconds(), _fiber, HashFileSystem);

            ChannelAdapter myChannel = new ChannelAdapter();

            _connection = myChannel.Connect(connectionConfigurator =>
            {
                connectionConfigurator.AddConsumerOf<FileSystemChanged>().UsingConsumer(HandleFileSystemChangedAndCreated);
                connectionConfigurator.AddConsumerOf<FileSystemCreated>().UsingConsumer(HandleFileSystemChangedAndCreated);
                connectionConfigurator.AddConsumerOf<FileSystemRenamed>().UsingConsumer(HandleFileSystemRenamed);
                connectionConfigurator.AddConsumerOf<FileSystemDeleted>().UsingConsumer(HandleFileSystemDeleted);
            });

            _fileSystemEventProducer = new FileSystemEventProducer(directory, myChannel, checkSubDirectory);
        }
开发者ID:jgsteeler,项目名称:Magnum,代码行数:33,代码来源:PollingFileSystemEventProducer.cs


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