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


C# Scheduler类代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var scheduler = new Scheduler();
            var random = new Random();
            for (var i = 0; i < 1000; i++)
            {
                var id = "Foo" + i;
                scheduler.Schedule(id, () =>
                {
                    return Task.Factory.StartNew(() =>
                    {
                        Console.WriteLine(id + " Started");
                        for (var a = 0; a < 10000 + random.Next(); a++)
                        {
                            Thread.Sleep(1);
                        }
                        Console.WriteLine(id + " Completed");
                    });
                }, TimeSpan.FromMinutes(3));
            }

            Console.WriteLine("S - to get starts, anything else to exit.");
            while (true)
            {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.S)
                {
                    Console.WriteLine("tats>> " + scheduler.GatherOveralStats());
                }
                else
                {
                    break;
                }
            }
        }
开发者ID:JustApplications,项目名称:inline_scheduler,代码行数:35,代码来源:Program.cs

示例2: Start

        public void Start()
        {
            // file system watcher will fail if directory isn't there, ensure it is
            if (!Directory.Exists(_baseDirectory))
                Directory.CreateDirectory(_baseDirectory);

            _scheduler = new TimerScheduler(new PoolFiber());
            _channel = new ChannelAdapter();

            _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, new PoolFiber(),
                                                           2.Minutes());

            _connection = _channel.Connect(config =>
                {
                    config
                        .AddConsumerOf<FileSystemEvent>()
                        .BufferFor(3.Seconds())
                        .UseScheduler(_scheduler)
                        .Distinct(fsEvent => GetChangedDirectory(fsEvent.Path))
                        .UsingConsumer(fsEvents =>
                            {
                                fsEvents.Keys.Distinct().Each(key =>
                                    {
                                        if (key == _baseDirectory)
                                            return;

                                        _serviceChannel.Send(new ServiceFolderChanged(key));
                                    });
                            })
                        .HandleOnFiber(_fiber);
                });
        }
开发者ID:haf,项目名称:Topshelf,代码行数:32,代码来源:DirectoryMonitor.cs

示例3: PeerSubscriptionCache

		public PeerSubscriptionCache(Fiber fiber, Scheduler scheduler, SubscriptionObserver observer)
		{
			_observer = observer;
			_fiber = fiber;
			_scheduler = scheduler;
			_endpoints = new Dictionary<Uri, EndpointSubscriptionCache>();
		}
开发者ID:shibukraj,项目名称:MassTransit,代码行数:7,代码来源:PeerSubscriptionCache.cs

示例4: ChooseNodegroup

        public ChooseNodegroup(string cluster)
        {
            InitializeComponent();

              listBox.Items.Clear();
              listBox.Items.Add("<Any>");

              if (cluster != "")
              {
            try
            {
              Scheduler scheduler = new Scheduler();
              scheduler.Connect(cluster);

              IStringCollection ngs = scheduler.GetNodeGroupList();
              foreach (String ng in ngs)
              {
            listBox.Items.Add(ng /*+ " (" + scheduler.GetNodesInNodeGroup(ng).Count().ToString() + ")" */ );
              }
            }
            catch
            {
            }
              }

              Mouse.OverrideCursor = null;
        }
开发者ID:ahorn,项目名称:z3test,代码行数:27,代码来源:ChooseNodegroup.xaml.cs

示例5: MakeInstance

	public static Scheduler MakeInstance ()
	{
		if (mInstance == null) {
			mInstance = Camera.main.gameObject.AddComponent<Scheduler>();
		}
		return mInstance;
	}
开发者ID:musicseli,项目名称:emoji,代码行数:7,代码来源:Scheduler.cs

示例6: Main

        static void Main(string[] args)
        {
            System.Console.WriteLine("Application started -  Esc to quit");

            var sessionFactory = NHibernateFactory.AssembleSessionFactory(DATABASE_FILE);
            ILog consoleLogger = new ConsoleLogger {VerbosityLevel = 2};
            ILog databaseLogger = new Logger(new LogEntryDatabaseRepository(sessionFactory)) {VerbosityLevel = 1};
            ILog log = new CompositeLogger(consoleLogger, databaseLogger);

            var iocContainer = new IocContainerForScheduler();
            iocContainer.BindToConstant(sessionFactory);
            var taskDirectory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName;

            var taskScheduler = new Scheduler(iocContainer, taskDirectory, new FileUtilities(), new TimerWithTimestamp(0, 10000), new TimerWithTimestamp(0, 2000), log);
            taskScheduler.Start();

            try
            {
                while (System.Console.ReadKey().Key != ConsoleKey.Escape) { }
            }
            catch (Exception e)
            {
                log.WriteEntry(new LogEntry(e.Source, e.Message, DateTime.Now));
            }
        }
开发者ID:ArildF,项目名称:Smeedee,代码行数:25,代码来源:Program.cs

示例7: EndpointSubscriptionCache

		public EndpointSubscriptionCache(Fiber fiber, Scheduler scheduler, SubscriptionObserver observer)
		{
			_fiber = fiber;
			_scheduler = scheduler;
			_observer = observer;
			_messageSubscriptions = new Dictionary<string, EndpointSubscription>();
		}
开发者ID:andreialecu,项目名称:MassTransit,代码行数:7,代码来源:EndpointSubscriptionCache.cs

示例8: ItShouldStartAndStopWithoutExceptions

 public void ItShouldStartAndStopWithoutExceptions()
 {
     var scheduler = new Scheduler(new FakeLoggerFactory());
     scheduler.Start();
     var stopped = scheduler.Stop().Wait(4000);
     Assert.True(stopped);
 }
开发者ID:loudej,项目名称:coral,代码行数:7,代码来源:SchedulerTests.cs

示例9: Start

        public void Start()
        {
            // file system watcher will fail if directory isn't there, ensure it is
            if (!System.IO.Directory.Exists(_baseDir))
                System.IO.Directory.CreateDirectory(_baseDir);

            _channel = new ChannelAdapter();
            FiberFactory fiberFactory = () => new SynchronousFiber();
            _scheduler = new TimerScheduler(fiberFactory());
            _producer = new PollingFileSystemEventProducer(_baseDir, _channel, _scheduler, fiberFactory(),
                                                           2.Minutes());

            _channel.Connect(config => config
                                           .AddConsumerOf<FileSystemEvent>()
                                           .BufferFor(3.Seconds())
                                           .Distinct(fsEvent => GetChangedDirectory(fsEvent.Path))
                                           .UsingConsumer(fsEvents => fsEvents.Keys.ToList().ForEach(key =>
                                               {
                                                   if (key == _baseDir)
                                                       return;

                                                   _hostChannel.Send(new FileSystemChange
                                                       {
                                                           ShelfName = key
                                                       });
                                               })));
        }
开发者ID:abombss,项目名称:Topshelf,代码行数:27,代码来源:DirectoryMonitor.cs

示例10: BenchmarkSystemTest

        /// <summary>
        /// Create some necessary parts and some dummy Jobs.
        /// </summary>
        public BenchmarkSystemTest()
        {
            scheduler = system.GetScheduler();

            Job1 = new Job(
                p => { Console.WriteLine("Job1 is running"); return 0; },
                "job1",
                "Michael",
                4,
                40
            );
            Job2 = new Job(
                p => { Console.WriteLine("Job2 is running"); return 0; },
                "job2",
                "Michael",
                4,
                5
            );
            Job3 = new Job(
                p => { Console.WriteLine("Job3 is running"); return 0; },
                "job3",
                "Michael",
                1,
                5
            );
            Job4 = new Job(
                p => { Console.WriteLine("Job4 is running"); return 0; },
                "job4",
                "Michael",
                6,
                10
            );
        }
开发者ID:Bladtman242,项目名称:SIDI-MMUN,代码行数:36,代码来源:BenchmarkSystemTest.cs

示例11: 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, [NotNull] Scheduler scheduler, Fiber fiber,
            TimeSpan checkInterval, bool checkSubDirectory)
        {
            if (scheduler == null)
                throw new ArgumentNullException("scheduler");

            _directory = directory;
            _channel = channel;
            _fiber = fiber;
            _hashes = new Dictionary<string, Guid>();
            _scheduler = scheduler;
            _checkInterval = checkInterval;

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

            var 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:akurtov,项目名称:Topshelf,代码行数:36,代码来源:PollingFileSystemEventProducer.cs

示例12: SetUp

        public override void SetUp()
        {
            base.SetUp();

            world = new World("Test", DateTime.Now, 2012);
            scheduler = new Scheduler();
        }
开发者ID:MilenPavlov,项目名称:EuroManager,代码行数:7,代码来源:SchedulerTests.cs

示例13: ScriptSystem

 /// <summary>
 /// Initializes a new instance of the <see cref="GameSystemBase" /> class.
 /// </summary>
 /// <param name="registry">The registry.</param>
 /// <remarks>The GameSystem is expecting the following services to be registered: <see cref="IGame" /> and <see cref="AssetManager" />.</remarks>
 public ScriptSystem(IServiceRegistry registry)
     : base(registry)
 {
     Enabled = true;
     Scheduler = new Scheduler();
     Services.AddService(typeof(ScriptSystem), this);
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:12,代码来源:ScriptSystem.cs

示例14: Shutter

        public Shutter(string openPin, string closePin, int delay, IHardwareAbstractionLayer hal)
        {
            if (string.IsNullOrEmpty(openPin))
                throw new ArgumentOutOfRangeException("openPin", "missing open pin");
            if (string.IsNullOrEmpty(closePin))
                throw new ArgumentOutOfRangeException("closePin", "missing close pin");
            if (delay == 0)
                throw new ArgumentOutOfRangeException("delay", "delay must be greater than 0");
            if (hal == null)
                throw new ArgumentNullException("hal");

            _openPin = openPin;
            _closePin = closePin;
            _delay = delay;
            _hal = hal;
            _scheduler = Scheduler.GetScheduler();

            //Stop motors on startup
            _hal.Write(_openPin, PinTypes.Output, 0);
            _hal.Write(_closePin, PinTypes.Output, 0);
            _status = StatusStop;

            Class = "Window";
            Hardware = _hal.Info.Name;
            Version = CLASS_VERSION;
        }
开发者ID:vinmenn,项目名称:HBus.DotNet,代码行数:26,代码来源:Shutter.cs

示例15: A_file_is_created

        public void A_file_is_created()
        {
            _baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            _filename = "test2.dat";
            _path = Path.Combine(_baseDirectory, _filename);

            System.IO.File.Delete(_path);

            _listener = new Future<FileCreated>();

            _channel = new ChannelAdapter();
            FiberFactory fiberFactory = () => new SynchronousFiber();
            _scheduler = new TimerScheduler(fiberFactory());
            _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, fiberFactory(),
                                                           20.Seconds());

            Thread.Sleep(5.Seconds());

            using (_channel.Connect(x => x.AddConsumerOf<FileCreated>().UsingConsumer(m => _listener.Complete(m))))
            {
                System.IO.File.Create(_path);

                _listener.WaitUntilCompleted(25.Seconds());
            }

            _producer.Dispose();
        }
开发者ID:sdhjl2000,项目名称:Magnum,代码行数:28,代码来源:PollingFileSystemWatcher_Specs.cs


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