Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


terryo
2009-11-02T16:38:48Z
I'm using the API to create/run/delete jobs, everthing works however there is a significant lag time(60+ secs) on the JobAddedStatic event firing after a job is added via the API using the same connection session. The first job added does not show this lag however every job added after the first during the session does have the lag. I can watch via the VisualCron Client and the jobs show up right away when added however its show the 2nd, 3rd, nth job as having a waiting status. Why is the job added event taking so long to fire and how do i fix this behavior? Attached is the log file
File Attachment(s):
vc_log.xls (26kb) downloaded 54 time(s).
Sponsor
Forum information
terryo
2009-11-03T22:13:59Z
Ok I can reproduce this quirky behavior with the TestClient app.

1) Add the following lines of code to btnAddExecuteJob_Click event:

Jobs.JobRemovedStatic += new Jobs.DelegateOnJobRemoved(Jobs_JobRemovedStatic);
j.RemoveAfterExecution = true;
s.Jobs.Run(j, true);

2) Add the follow method:

void Jobs_JobRemovedStatic(ref Server server, JobClass job)
{
btnAddExecuteJob_Click(null,null);
}

3) To reproduce:
A) run the TestClient app
😎 click on "Connect remote" button
C) click on "Add Job with Execute task" button
D) after Notepad starts up close it
E) at this point the new Notepad job shows up to run in VisualCron
but it won't start running until ~60+ secs later.

Attached is the log from the test.
File Attachment(s):
vc_testclient_log.xls (15kb) downloaded 51 time(s).
Support
2009-11-03T22:18:05Z
Seems like a threading/lock problem. Try execute the Add in another (new) thread than the removed event.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
terryo
2009-11-04T01:42:22Z
I tried your suggestion but I get the same quirky behavior. I modified the TestClient app with the following code:

delegate void UICaller(object sender, EventArgs e);

void Jobs_JobRemovedStatic(ref Server server, JobClass job)
{
if (this.InvokeRequired)
{
this.Invoke(new UICaller(btnAddExecuteJob_Click), new object[] { null, null });
}
else
{
btnAddExecuteJob_Click(null, null);
}
}

The API is now called in the same thread as the first job but it still doesn't run it until after the 60+ secs lag time. Also my code runs in a service so I'm confused as to what thread the API would run under? Seems to me the API should be responsible for it's own thread safety. This behavior looks like a bug.
Support
2009-11-04T19:35:42Z
Currently we have a lock which prevents calling those functions during that event. We will shuffle around some code for next release.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2009-11-04T22:07:40Z
Please test this problem with the version below. Thank you for your findings.

http://www.visualcron.co...m.aspx?g=posts&t=932 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
terryo
2009-11-05T21:24:16Z
Tried the 5.3.8 beta using the TestClient app with the above modified code and it behaves the same as before(5.3.1). The first job is added and runs, the 2nd job is added but you still get the 60+ sec lag time before it starts running.
Support
2009-11-06T16:41:41Z
OK, we are debugging this issue now.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2009-11-06T21:02:48Z
terryo
2009-11-06T22:46:52Z
Ran 5.3.9 and it has worst quirky behavior than 5.3.8. Attached is the actual code from the TestClient that I'm running. The mods are in red/bold. When I run the test it goes into a goofy repetitive cycle of add/delete jobs. To run the test do the following steps:

1) make the code mods to the TestClient code
2) the client/server are running on different PCs
3) run VisualCron client on client PC
3) start the TestClient on client PC
4) click on "Connect remote" and waitfor connection
5) click on "Add Job with Execute task"

Ideally I would like to make the API call to run the job from the OnJobAdded event.
File Attachment(s):
vcquirky.doc (64kb) downloaded 58 time(s).
Support
2009-11-06T23:03:32Z
With this code you will get very strange behavior after having connected twice as you add the static events every time you connect.

What we did as a change was to remove a lock in the static event (when Job was removed) which caused a dead lock because you were trying to add in the remove event.

I am still not sure what you are trying to do and the reason why you are trying to add (and run) it when it is removed? Why not keep it all the time? We need to understand you want to accomplish.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2009-11-06T23:05:25Z
Also, there will of course be a loop here because your Job will deleted when it has run and then you add it and run it again.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
terryo
2009-11-07T17:34:29Z
It really is quite simple what I want to do and what the API should be able to do which is during the JobRemove event I should be able to create a new job and run it. In my scenario I have a service which monitors a MySql database that users interface via a web browser. When the service determine that a user needs a job run, it creates a VisualCron job and starts it. When the VisualCron job is done it deletes itself. During the JobRemove event the service looks to see if another user job needs to be run and if so creates it and runs it. This is the exact same scenario I tried to get the TestClient code to emulate(which it does) because I thought it would be easier for you guy to debug the problem with that code rather than spelunking thru my service code. Now in my app, things work except in the above scenario where a job is create during the JobRemove event and you get the 60+ sec lag time before the job
starts running. As to your question as to why not kept jobs that is because the users make up their jobs to run and the parameters to use, so most jobs are unique. This last version of 5.3.9, I don’t know what it’s doing but what the TestClient is suppose to do is reproduce the bug above by creating and running notepad(my user's job), I close notepad(user job ends) and then VisualCron deletes the job, fires the event at which point a new job of notepad is created and start to runs right away(no lag time). It’s not doing that at all.

One more thing, I believe there is also a problem with the JobAdded event. When that event fires I think you should be able to start/run the job in that event, but the API doesn't seem to let you do that either.
Support
2009-11-07T17:45:21Z
Perhaps misunderstood you. But you said it went into a loop which is not strange at all when looking at your sample.

What we tested, before release of 5.3.9. was the first sample which run without a problem - except that it is a loop that went on forever.

It was indeed a deadlock problem before because we had locks in Added and Removed event. The add deadlock was removed in 5.3.8. and the remove deadlock was removed in 5.3.9.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2009-11-07T17:57:23Z
We tested your latest code now and it did work without problems except:

1. it will loop forever. Whenever notepad is closed it will be started again.
2. the static events should be at startup level - not at connect level (otherwise it might be a risk that you get double events because you never remove any events)
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top