Cancel Scriptjob By Variable?

Is it possible to assign a script job to a particular number or cancel a specific script job by the variable that it is assigned to?

I'm having a "SelectionChanged" event run a proc, but need to cancel that particular script Job if certain conditions within the proc are met...

is this possible?

you never need to manually assign a particular number to a scriptJob as the return value of the scriptJob is it's job number, so you can just store this and use it to kill the job. Just take a look at the examples in the scriptJob MEL doc.

you can also parent the scriptJob to some UI, so when the UI is closed, the scriptJob is automatically killed. You could always create a hidden window and kill it to kill the parented scriptJob without knowing it's number...

:nathaN

Or you can allways use scriptJob -lj to get a list of ALL jobs and whats tied to them and killl based on the number in the listing.