1.    18 Feb 2017 #1
    Join Date : Aug 2015
    Posts : 78
    Windows 10

    Actions in Task Scheduler


    I have two Scheduled tasks whose actions start the same program, but with different parameters. If these two program instances happen to get scheduled at more or less the same time, then one will wait for the other to finish.

    But it seems to me that sometimes the one which should start second fails to start at all. There is nothing in my code which stops the programs overlapping, apart from their own semaphore mechanism.

    Is there anything in the Task Scheduler itself that would prevent the second task triggering?

    The tasks are triggered by the events "Workstation lock" and "Workstation unlock"; the scheduled task runs a program which turns the display off and on. So, the effect is that the screen always blanks when the desktop locks, and it comes back on when the desktop unlocks.
    Sometimes, the events happen so close to each other than the "display on" and "display off" programs might try to run almost simultaneously, hence my semaphore arrangement,
      My ComputerSystem Spec
  2.    18 Feb 2017 #2
    Join Date : Apr 2015
    Posts : 229
    Windows 10 x64 v1703

    Never had occasion to review Scheduler Events myself but try event logs to see if they're helpful in seeing what's up.

    Open Task Scheduler. In right pane click Enable All Task History.

    After tasks run, right click the task->Properties and click History tab. (events are listed in reverse time order)


    You can also see all events for all tasks in Event Viewer. Click Applications and Services->Microsoft->Windows->TaskScheduler
      My ComputerSystem Spec
  3.    18 Feb 2017 #3
    Join Date : Aug 2015
    Posts : 78
    Windows 10
    Thread Starter

    OK, I'll give the Event Viewer a go. Because the events include the desktop locking, and the display powering off, it gets a bit tricky trying to see what's going on. Even the event viewer might be difficult... by the time I've got the desktop to unlock and the display to come out of power saving mode, the events of interest may be some way back in the log.
    Time for bed for me now. Back tomorrow.
      My ComputerSystem Spec
  4.    18 Feb 2017 #4
    Join Date : Jul 2015
    Posts : 3,755
    10 Pro

    What do you mean semaphore mechanism? Do you mean some .Net thing that is "not tidy or clearly defined" Source

    Why not try to allocate an object (get an exclusive lock some temporary text file or something) and just wait until you can? Then neither program can interfere with the other.

    I'm not much of a Windows programmer - I would use ALCOBJ if it existed but something like this perhaps?

    windows - How to get an exclusive lock on a file using batch file? - Stack Overflow
      My ComputerSystem Spec
  5.    19 Feb 2017 #5
    Join Date : Apr 2015
    Posts : 229
    Windows 10 x64 v1703

    yea, logs won't tell you the detail of what's happening within the task but can answer which tasks run in which order and whether answer your question if the 2nd task runs. Might help provide some debug clues
      My ComputerSystem Spec
  6.    19 Feb 2017 #6
    Join Date : Aug 2015
    Posts : 78
    Windows 10
    Thread Starter

    Quote Originally Posted by lx07 View Post
    Why not try to allocate an object (get an exclusive lock some temporary text file or something) and just wait until you can? Then neither program can interfere with the other.
    That's exactly what I'm doing. The scripting language that I use reads the source code, then closes the file. So the program itself is the file that I use for my semaphore. I just get an exclusive read lock on the program, and I'm away.
    However, some of the scheduled tasks seem not to be running. I get an audible signal that the task should be running, but there's no record in the trace log generated by my program which is the action of the scheduled task.
    The first act of my program is to create a "started" trace entry, and it's these records which are not always appearing.
    If any error occurs in the tracing, the program immediately pauses and waits for me to investigate. This has never happened.

    So, tearing my hear out, I started wondering if there were some locking mechanism in the task scheduler, preventing two tasks colliding when their action is the same program.
    I'm shooting in the dark here...

    For completeness: I have a proximity device that locks and unlocks my desktop depending on where I am. As I approach the PC, I hear the Windows notification sound for the unlock event. This should trigger my "desktop unlocked" scheduled task, but this sometimes doesn't happen. This leaves me with a black screen, which hinders the debugging.
    I'm trying to get the proximity device manufacturer to trace the code around the unlock process, to see if that is failing. But if so, why am I hearing the unlock sound?
      My ComputerSystem Spec

 


Similar Threads
Thread Forum
Backup & Restore Import Task to Task Scheduler in Windows
How to Import a Task to Task Scheduler in Windows The Task Scheduler enables you to automatically perform routine tasks on a chosen computer. The Task Scheduler does this by monitoring whatever criteria you choose to initiate the tasks (referred...
Tutorials
Backup & Restore Export Task from Task Scheduler in Windows
How to Export a Task from Task Scheduler in Windows The Task Scheduler enables you to automatically perform routine tasks on a chosen computer. The Task Scheduler does this by monitoring whatever criteria you choose to initiate the tasks...
Tutorials
Task Scheduler run task when logged in Remotely
Hey everyone I tried using this guide (How To Easily Send Emails From The Windows Task Scheduler) to create a task that will send me an email whenever someone connects with RDP.The task works and sends the email if i run it, but i am unsure how to...
General Support
How to show Command Prompt Window when running task in Task Scheduler?
Is there a way to make the "Command Prompt" window show when I have a task running in Windows task Scheduler? I would like to be able to view the progress of the task. For example, I have a program called "Zap2xml" that collects TV EPG data. It...
General Support
Solved Time Zone change causes error in Task Scheduler for every task
My issue is kind of strange. I am an insider currently on Windows 10 build 10240. All the build I have tried so far has this same error in task scheduler when I change my time zone to my current location which is kathmandu (UTC+5:45). When i change...
Performance & Maintenance
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 13:54.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums