Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

Closed Unassigned: Property Task.Enabled is not saved [11703]

$
0
0
I am using Microsoft.Win32.TaskScheduler.dll in an appliction to create and change a task. If I set the property Task.Enabled to False it will not be saved to Windows. All other information is saved properly.

Code:

Dim Task1 As Task = CurrentTaskService.RootFolder.RegisterTaskDefinition(PathOfTask, TaskDefinition1)
Task1.Enabled = False
Task1.RegisterChanges()

This was working properly in build 2.0.3, but does not work in build 2.2.0.
Comments: Below is the code you should have and it works:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If ListView1.SelectedIndices.Item(0) >= 0 Then
Me.Enabled = False
Dim Task1 As Task = ListView1.SelectedItems(0).Tag
Task1.Enabled = Not Task1.Enabled
ListView1.SelectedItems(0).SubItems(1).Text = CType(Task1.Enabled, String)
Me.Enabled = True
HandleButton()
End If
End Sub

Private Sub LoadAllTasks()
ListView1.Items.Clear()
ListView1.BeginUpdate()
For Each Task1 As Task In TaskService1.FindAllTasks(Nothing, False)
Dim LVitem As New ListViewItem(Task1.Name)
LVitem.SubItems.Add(CType(Task1.Enabled, String))
LVitem.Tag = Task1
ListView1.Items.Add(LVitem)
Next
ListView1.EndUpdate()
If ListView1.Items.Count > 0 Then
ListView1.Items(0).Selected = True
ListView1.Items(0).EnsureVisible()
End If
End Sub

Viewing all articles
Browse latest Browse all 2206

Trending Articles