Cannot reuse a trigger? #964
-
Shared ReadOnly ValidTriggers As Trigger() = {New DailyTrigger(1), New DailyTrigger(2), New DailyTrigger(4), New WeeklyTrigger(1), New WeeklyTrigger(2), New MonthlyTrigger(1)} I provide a ComboBox for the user to select a trigger to use. I get its SelectedIndex and use the index to get the corresponding trigger in a preloaded triggers array, and then add a task with this trigger. However, if the user select the same trigger twice, it throws NullReferenceException. |
Beta Was this translation helpful? Give feedback.
Answered by
dahall
May 15, 2023
Replies: 1 comment
-
Yes. I would use the task.Defnition.Triggers.Add((Trigger)ValidTriggers[selectedIndex].Clone()); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dahall
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes. I would use the
Clone
method on the trigger before adding it to theTriggers
of the task.