This project has moved. For the latest updates, please go here.

Refresh method issue

Feb 20, 2012 at 10:54 AM

Hi,

 I have some troubles using refresh method of task class and state property.
Using this code on WIN 2003 SERVER the job state never changes its value:

currentJob = t.Run(b.Arguments)

logMgr.Debug(" job state: " & currentJob.State & " Lastrun: " & currentJob.LastRunTime)
Threading.Thread.Sleep(1000)

While t.State = TaskState.Running Or t.LastRunTime.CompareTo(d) < 0
  Threading.Thread.Sleep(2000)

currentJob.Refresh()
logMgr.Debug(" job state: " & currentJob.State & " last run time: " & currentJob.LastRunTime) End While

Now I use the following workaround but I would like to know if someone has a similar issue with refresh() method.

While t.State = TaskState.Running Or t.LastRunTime.CompareTo(d) < 0
  Threading.Thread.Sleep(2000)
  t = s.FindTask(b.JobName)
  logMgr.Debug(" job state: " & t.State & " last run time: " & t.LastRunTime)
End While

thanks,

F.

Coordinator
Feb 21, 2012 at 7:11 AM

The RunningTask.Refresh method is not supported under V1 of the Task Scheduler (pre Vista systems). In doing some research, I found a problem in the V1 code which I have corrected. The Microsoft help on IScheduledWorkItem::GetStatus states that this does not return the state dynamically under V1. I have updated the code so that I am refetching the interface before returning the state. Version 1.8.1 should have the fix in place.

Feb 22, 2012 at 1:39 PM

Good. Thank you very much.