本文整理汇总了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();
}
示例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();
});
}
示例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);
}
示例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");
}