here i am giving a small my code snippet just to show what i am trying to achieve.
private void frmMain_Load(object sender, EventArgs e)
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
sched = schedFact.GetScheduler();
sched.Start();
IJobDetail job = JobBuilder.Create<frmMain>()
.WithIdentity("Job", "group")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(01, 55))
)
.Build();
sched.ScheduleJob(job, trigger);
}
public void Execute(IJobExecutionContext context)
{
generate();
}
public void generate()
{
if (this.FetchStart != null)
this.FetchStart(this, new EventArgs());
System.Threading.Thread.Sleep(5000);
if (this.FetchDone != null)
this.FetchDone(this, new EventArgs());
}
i have done my project with VS2013 community edition. my objective is to call slide show routine every day at specific time. when i am calling my slide show routine without quartz.net scheduler then it is working fine but when i invoke my routine by quartz.net scheduler then routine is getting called but no slide show image is showing.
what [problem occur is not clear to me. as per my objective i have to use quartz.net scheduler because i need to invoke my routine at a specific time of day every day.
here i am sharing my project code because it is in onedrive. so my request please some one download my project and run at your end to see the problem and tell me the reason which causes not to show images on picture box.
if possible please rectify my code with quartz.net scheduler code. one drive project link is https://1drv.ms/f/s!AmIfMNV-CodPa81zFiNH6Ur7qro
i upload my project folder.
thanks
UPDATE
when i use background worker along with quartz.net to call my generate routine then also no improvement i found. same problem that slide show image is not appearing on picture box.
here is the code for quartz.net with background worker
public partial class frmMain : Form, IJob
{
ucSlide oSlide = new ucSlide();
IScheduler sched = null;
BackgroundWorker m_oWorker = null;
public event EventHandler FetchStart;
public event EventHandler FetchDone;
public event EventHandler NoDataFound;
public frmMain()
{
InitializeComponent();
m_oWorker = new BackgroundWorker();
m_oWorker.DoWork += new DoWorkEventHandler(m_oWorker_DoWork);
m_oWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_oWorker_RunWorkerCompleted);
oSlide.MainForm = this;
oSlide.SlideSource = Utility.SlidePath;
this.Controls.Add(oSlide);
oSlide.Dock = DockStyle.Fill;
}
private void frmMain_Load(object sender, EventArgs e)
{
// construct a scheduler factory
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
sched = schedFact.GetScheduler();
sched.Start();
IJobDetail job = JobBuilder.Create<frmMain>()
.WithIdentity("Job", "group")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(02,23))
)
.Build();
sched.ScheduleJob(job, trigger);
}
public void Execute(IJobExecutionContext context)
{
m_oWorker.RunWorkerAsync();
}
public void generate()
{
if (this.FetchStart != null)
this.FetchStart(this, new EventArgs());
System.Threading.Thread.Sleep(5000);
if (this.FetchDone != null)
this.FetchDone(this, new EventArgs());
}
void m_oWorker_DoWork(object sender, DoWorkEventArgs e)
{
generate();
}
void m_oWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// The background process is complete. We need to inspect
// our response to see if an error occurred, a cancel was
// requested or if we completed successfully.
//if (e.Cancelled)
//{
// //lblStatus.Text = "Task Cancelled.";
// isBusy = false;
//}
//// Check to see if an error occurred in the background process.
//else if (e.Error != null)
//{
// //lblStatus.Text = "Error while performing background operation.";
// MessageBox.Show(e.Error.InnerException.Message.ToString());
// isBusy = false;
//}
//else
//{
// // Everything completed normally.
// //lblStatus.Text = "Task Completed...";
// isBusy = false;
//}
}
}
thanks