Issue creating a scheduled task

Discussions related to SoftPro Select Server development.

Moderator: Phil Barton

Post Reply
dn_garza
Posts: 25
Joined: Wed Jan 10, 2024 11:16 pm

Issue creating a scheduled task

Post by dn_garza »

I've attempted using a code snippet found on the forum to start a scheduled task. I'm getting an thrown exception. Any ideas? In the screenshot, 'trigger' is of type IScheduledTrigger. Is it possible that this is causing the issue on 'tm.ApplyChanges(trigger)'? 'ApplyChanges' per the docs says to pass a trigger of type 'ITrigger'.
schedulerIssue.png
schedulerIssue.png (88.62 KiB) Viewed 1067 times
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Issue creating a scheduled task

Post by BobRichards »

Please post the source code and exception call stack.
Bob Richards, Senior Software Developer, SoftPro
dn_garza
Posts: 25
Joined: Wed Jan 10, 2024 11:16 pm

Re: Issue creating a scheduled task

Post by dn_garza »

I resolved this. I think my issue was that I was performing this operation before the services were available. Question on the topic - in order to get the scheduled task not to be added as a scheduled task every time the package loads, what would be a clear and simple solution? Is there some table that I can set some value on and read as a condition to registering the scheduled task?
PaulMcCullough
Posts: 23
Joined: Wed Jul 12, 2023 11:29 am

Re: Issue creating a scheduled task

Post by PaulMcCullough »

Yes. To check your trigger has already been created, check the [core].[Trigger] table for a row where the Handler column matches the id of your ITriggerHandler. If it exists, then your trigger is already created and you should not create it again.
Post Reply