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


C# IScheduler.Stop方法代码示例

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


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

示例1: OnStart

 public void OnStart(IScheduler scheduler, string[] args)
 {
     OnStartCalls++;
     OnStartArgs = args;
     Startup.Scheduler = scheduler;
     if (StopOnStart)
         // anything already queued will continue to run.
         // XXX kind of hate the semantics of this
         // fuck the state.
         scheduler.Stop();
 }
开发者ID:ruxo,项目名称:kayak,代码行数:11,代码来源:LauncherTests.cs

示例2: LinkTo

    public void LinkTo(ITargetBlock<string> target, CancellationToken token)
    {
      _target = target;
      IsListening = true;
      _scheduler = KayakScheduler.Factory.Create(new SchedulerDelegate());
      var wsTask = Task.Factory.StartNew(() =>
        {
          var server = KayakServer.Factory.CreateHttp(
            new RequestDelegate(this),
            _scheduler);

          using (server.Listen(new IPEndPoint(IPAddress.Any, _port)))
          {
            _scheduler.Start();
          }
          IsListening = false;
        });

      Task.Factory.StartNew(() =>
        {
          token.WaitHandle.WaitOne();
          _scheduler.Stop();
        });
    }
开发者ID:joshclark,项目名称:statsd.net,代码行数:24,代码来源:HttpStatsListener.cs

示例3: SetUp

        public void SetUp()
        {
            ep = new IPEndPoint(IPAddress.Loopback, Config.Port);

            wh = new ManualResetEventSlim();

            schedulerDelegate = new SchedulerDelegate();
            scheduler = new DefaultKayakScheduler(schedulerDelegate);

            schedulerDelegate.OnStoppedAction = () =>
            {
                stopListening.Dispose();
                stopListening = null;
                wh.Set();
            };
            schedulerDelegate.OnExceptionAction = e =>
            {
                schedulerError = e;
                Debug.WriteLine("Error on scheduler");
                e.DebugStackTrace();
                scheduler.Stop();
            };

            scheduler.Post(() =>
            {
                stopListening = server.Listen(ep);
                schedulerStartedAction();
            });

            serverDelegate = new ServerDelegate();
            server = new DefaultKayakServer(serverDelegate, scheduler);

            clientSocketDelegate = new SocketDelegate();
            client = new DefaultKayakSocket(clientSocketDelegate, scheduler);
        }
开发者ID:reider-roque,项目名称:Elpis,代码行数:35,代码来源:NetTests.cs

示例4: Main

        static void Main()
        {
            DependableJobsTable.Create(ConfigurationManager.ConnectionStrings["Default"].ConnectionString);

            _scheduler = new DependableConfiguration()
                .SetDefaultRetryCount(2)
                .SetDefaultRetryDelay(TimeSpan.FromSeconds(1))
                .SetRetryTimerInterval(TimeSpan.FromSeconds(1))
                .UseSqlPersistenceProvider("Default", "TestHost")
                .UseConsoleEventLogger(EventType.JobStatusChanged | EventType.JobSuspended)
                .Activity<Greet>(c => c.WithMaxQueueLength(3).WithMaxWorkers(3))
                .CreateScheduler();

            _scheduler.Start();

            Console.WriteLine("Dependable Examples");
            Console.WriteLine("1. Single Activity");
            Console.WriteLine("2: Activity Sequence");
            Console.WriteLine("3. Parallel Activity");
            Console.WriteLine("4. Logger Filter");
            Console.WriteLine("5. Exception Filter");
            Console.WriteLine("6. Job cancellation");

            var option = Convert.ToInt32(Console.ReadLine());

            switch (option)
            {
                case 1:
                    _scheduler.Schedule(
                        Activity.Run<Greet>(g => g.Run("alice", "cooper")).Then<Greet>(g => g.Run("bob", "jane")));
                    _scheduler.Schedule(Activity.Run<Greet>(g => g.Run("bob", "jane")));
                    _scheduler.Schedule(Activity.Run<Greet>(g => g.Run("kyle", "simpson")));
                    _scheduler.Schedule(Activity.Run<Greet>(g => g.Run("andrew", "matthews")));
                    break;
                case 2:
                    var sequence = Activity
                        .Sequence(
                            Activity.Run<Greet>(g => g.Run("a", "b")),
                            Activity.Run<Greet>(g => g.Run("c", "d")))
                        .ExceptionFilter<LoggingFilter>((c, f) => f.Log(c, "hey"))
                        .AnyFailed<Greet>(g => g.Run("e", "f"))
                        .Cancelled<GreetCancelled>(d => d.Run())
                        .ThenContinue()
                        .Then<Greet>(g => g.Run("g", "h"));
                    _scheduler.Schedule(sequence);
                    break;
                case 3:
                    _scheduler.Schedule(Activity.Parallel(
                        Activity.Run<Greet>(g => g.Run("a", "b")).Then<Greet>(g => g.Run("e", "f")),
                        Activity.Run<Greet>(g => g.Run("g", "h")).Then<Greet>(g => g.Run("i", "j"))
                        ));
                    break;
                case 4:
                    _scheduler.Schedule(
                        Activity
                            .Run<Greet>(g => g.Run("buddhike", "de silva"))
                            .ExceptionFilter<LoggingFilter>((c, f) => f.Log(c, "something was wrong")));
                    break;
                case 5:
                    _scheduler.Schedule(
                        Activity.Run<Greet>(g => g.Run("c", "d"))
                            .ExceptionFilter<LoggingFilter>((c, f) => f.Log(c, "ouch"))
                            .Failed<Greet>(g => g.Run("a", "b")));
                    break;
                case 6:
                    Console.WriteLine("Enter 'y' to initate job cancellation at any time");
                    Console.WriteLine("Press any key to start the schedule");
                    Console.ReadLine();

                    _stopToken = Guid.NewGuid();
                    _scheduler.Schedule(Activity.Run<DueSchedule>(d=>d.ExecuteSchedule()).Cancelled(Activity.Run<DueSchedule>(d=>d.CancelExecute())), _stopToken);

                    if (ConsoleKey.Y == Console.ReadKey().Key)
                    {
                        _scheduler.Stop(_stopToken);
                    }
                    break;
            }

            Console.ReadLine();
            Console.WriteLine("Press enter to cleanup completed jobs");
            Console.ReadLine();

            DependableJobsTable.Clean(ConfigurationManager.ConnectionStrings["Default"].ConnectionString, "TestHost");
        }
开发者ID:inprotech-dev,项目名称:dependable,代码行数:85,代码来源:Program.cs


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