dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.21k stars 191 forks source link

Question: How to add TaskScheduler to own GUI #873

Closed Torchok19081986 closed 3 years ago

Torchok19081986 commented 3 years ago

Hallo, i have a difficulty to add Task to my gui. Which class i should use ? im right if i use "normal" taskscreation ? Is there posibilty to sync windows Taskscheduler and own gui , somehow? Following scenario : task can be created and it creates new Task in windows , probably works fine, what if user change it in windows and not changing it in gui ? Some syncronisation call all new changes at start ? I just dont know wher at this point to start.

dahall commented 3 years ago

Look in the TaskSchedulerMockup project and see how I've recreated the Windows GUI. All of the classes that list tasks or task folders are auto-updating. The control that displays a single Task for editing does not so that a user doesn't lose changes they've made. There is a TaskEventWatcher class you can use to be alerted when tasks change.

Torchok19081986 commented 3 years ago

Ok, many thanks for quick response. last question: i cant start any form. Rebuild breaks with error MD5 Checksum cant be opened. ...

dahall commented 3 years ago

Try cleaning and then building the entire solution. I was actually suggesting you look at the code to see how different classes are used. It is not a very complicated piece of code.

Torchok19081986 commented 3 years ago

got it. I changed target framekwork to 5.0-windows and it runs. I try to test it on Windows server 2016 and 2019 . A Message appears : " Operation it not supported on this platform " . Net 5.0 windows runtime is installed and my VM, a hyper-v Testsystem runs normally. After message was clicked with OK, a windows form appears and it looks exactly like windows Taskscheduler. Have tested all actions. Only after press refresh Exception appears.

Windows server 2019 and logged in as Domain Admin. Verion 1809 (build 17763.1757)

dahall commented 3 years ago

Here is a build that should work. It is built for .NET 4.52 and should be run as Admin. TaskSchedulerMockup_v4.5.2.zip

Torchok19081986 commented 3 years ago

Thanks. Net 5.0 problem or why ?

dahall commented 3 years ago

So to your original question, which portions of the UI do you wish to add to your app?

Torchok19081986 commented 3 years ago

just tested it. Runs without problem. Exception doesnt appear anymore. Only task creation and if user change it .

dahall commented 3 years ago

So there are two classes to consider, both in the Microsoft.Win32.TaskSchedulerEditor package:

  1. TaskPropertiesControl: hostable control that provides a configurable editor for a task
  2. TaskEditDialog: A dialog that hosts TaskPropertiesControl with all the same capabilities.
Torchok19081986 commented 3 years ago

Ok, again, many thanks. Last question after that , please close my question. Which targetframework should be set for compiler target ? i would like to use net core 3.1/5.0 , but somehow it not working on taskscheduler V1.

dahall commented 3 years ago

I have fully tested with .NET 2.0-4.52 and only partially with .NET Core 3.1 and 5.0. Let me do some further testing there and then I'll reply with my findings.

dahall commented 3 years ago

The libraries will work with .NET 5.0, but not the Mockup example. I need to redo the threading model on the example. It is using APM which is not supported on .NET 5.0. That's rework I don't have time for at the present. However, seeing how those components are used in the example should help you deploy your solution.