我有一段時間需要與ftp服務器進行通信,並將其託管在雲中。要在託管服務器中運行計劃任務,我該怎麼辦?如果有人能指點我一個有用的在線資源,那將是非常棒的。在託管服務器中定期安排一項任務c#
在此先感謝..
我有一段時間需要與ftp服務器進行通信,並將其託管在雲中。要在託管服務器中運行計劃任務,我該怎麼辦?如果有人能指點我一個有用的在線資源,那將是非常棒的。在託管服務器中定期安排一項任務c#
在此先感謝..
我用http://hangfire.io/這一點,它是功能強大,但使用起來非常簡單。
您也可以使用http://www.quartz-scheduler.net/,但我沒有使用它,所以我不能評論它。
我用石英,它是真棒和直接前進。
使用的一個簡單的例子是這樣的:
using Quartz;
private ScheduleCopyTask()
{
Quartz.IScheduler sched;
IJobDetail job;
ITrigger trigger;
// Instantiate the Quartz.NET scheduler
var schedulerFactory = new Quartz.Impl.StdSchedulerFactory();
sched = schedulerFactory.GetScheduler();
sched.Start();
// Instantiate the JobDetail object passing in the type of your
// custom job class. Your class merely needs to implement a simple
// interface with a single method called "Execute".
job = JobBuilder.Create<SyncJob>()
.WithIdentity("SyncJob", "group1").Build();
// Trigger the job to run now, and then every 30 mins
trigger = TriggerBuilder.Create()
.WithIdentity("SyncTrigger", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(30)
.RepeatForever()).Build();
sched.ScheduleJob(job, trigger);
}
,你的任務等級:
class SyncJob : IJob
{
public void Execute(IJobExecutionContext context)
{
// your task goes here
}
}
你可以找到石英文檔在這裏:http://quartz-scheduler.org/generated/2.2.1/html/qs-all/
你可以用'Timer',你不能嗎? –
是的,我不確定,我是否應該創建一個定期運行的Web服務?在雲中託管服務後,它將自動運行,無需任何用戶交互。 –
在您的雲計算機中,沒有任務計劃程序或支持cron作業命令? – HarryQuake