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

Hung Scheduled Task Won't Stop

Topics: Errors
May 16, 2013 at 3:29 PM
Hello,

We've been using this API to manage scheduled tasks (mostly by enabling them and disabling them) on a number of remote servers during software deployments, and it works quite well the majority of the time.

Occasionally, however, we run into a situation where a scheduled task gets "hung" (remains in a "Running" state perpetually, even though it's not actually doing any work). This happens most often on servers with slower connections, although it happens on faster servers as well with a decreased regularity.

I've been able to recreate the situation relatively easily by creating the conditions outlined here:
http://blogs.technet.com/b/rspitz/archive/2010/11/07/scheduled-tasks-appear-hung-in-the-running-state-on-windows-server-2003-based-systems.aspx

While in this state, we can't stop the task (either through the Task.Stop() API call or through the Windows Scheduled Task interface) and are forced to restart the Task Scheduler service to free it up.

Since the Windows interface doesn't seem to allow us to stop tasks in this condition I don't have much hope for the API, but I have to ask: Has anyone here encountered this before and found a way to deal with it and/or avoid it when using this API?
Aug 18, 2014 at 2:50 PM
The same scenario has happened to me once before. I haven't found a solution other than the restart of service. Mind it's only happened once so haven't given it more time, will let you know if I do.