Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to disable a Scheduled Task in code?How to disable a Scheduled Task in code?
Previous
 
Next
New Post
5/23/2009 10:48 PM
 

Hi,

I have a task that turns itself off once it has finished processing:

                SchedulingController schedulingController = new SchedulingController();
                ScheduleItem proximtyMailerScheduleItem = schedulingController.GetSchedule("SmartThinker.DNN.Modules.UserProfile.UserProfileProximityMailerTask, SmartThinker.DNN.Modules.UserProfile", "");
                proximtyMailerScheduleItem.Enabled = false;
                schedulingController.UpdateSchedule(proximtyMailerScheduleItem.ScheduleID, proximtyMailerScheduleItem.TypeFullName, proximtyMailerScheduleItem.TimeLapse, proximtyMailerScheduleItem.TimeLapseMeasurement, proximtyMailerScheduleItem.RetryTimeLapse, proximtyMailerScheduleItem.RetryTimeLapseMeasurement, proximtyMailerScheduleItem.RetainHistoryNum, proximtyMailerScheduleItem.AttachToEvent, proximtyMailerScheduleItem.CatchUpEnabled, proximtyMailerScheduleItem.Enabled, proximtyMailerScheduleItem.ObjectDependencies, proximtyMailerScheduleItem.Servers);
                auditTrail += "| Finished Processing, Disabled";

 

I noticed that it actually keeps running despite it not being enabled. I think the Scheduler checks the last record in the History table and checks the NextStartTime and runs it regardless of whether the task is enabled or not. I consider this a bug - any thoughts on this?

How should I therefore disable the task? Make a call to the last ScheduleHistoryItem and erase it so it clears the Next Start time?

 


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
5/23/2009 11:18 PM
 

what version are you running? Also, how often was it scheduled to run before you disabled it? Any chance maybe the cache object didn't get cleared and it's just thinks it's still enabled?

 
New Post
5/24/2009 8:11 AM
 

DNN 4.9.2.

It's every 15 minutes so I don't think it is a caching issue as it keeps running every 15 from then on. Although maybe you are right - I'll kill the ASP process half way through and see if it starts again... ta


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
5/26/2009 3:57 AM
 

Ok, when I killed the process it did NOT run again, so perhaps it is something to do with the cache.

I checked the core code and tried this:

                SchedulingController schedulingController = new SchedulingController();


               


                ScheduleItem proximtyMailerScheduleItem = schedulingController.GetSchedule("SmartThinker.DNN.Modules.UserProfile.UserProfileProximityMailerTask, SmartThinker.DNN.Modules.UserProfile", "");


                proximtyMailerScheduleItem.Enabled = false;


                proximtyMailerScheduleItem.NextStart = Null.NullDate;


               


                DNNScheduler.Instance().UpdateSchedule(proximtyMailerScheduleItem);


                DotNetNuke.Common.Utilities.DataCache.RemoveCache("ScheduleLastPolled");


UpdateSchedule in SchedulingProvider.vb seems to do some cache clearing and other stuff but I had no joy with the above code.

The only other thing I can think of is to grab all the ScheduledItemHistories by ScheduleID (it returns an arraylist) and get the last one and nullify the NextStart time and write it back but this seems very verbose.

Can anyone who knows the Scheduler comment on how to disable an item in code please?


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
5/26/2009 1:38 PM
 

You might try clearing "ScheduleQueue" as well...

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to disable a Scheduled Task in code?How to disable a Scheduled Task in code?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out