How to detect locked screen in Tasker? If like to be able to detect a locked screen in Tasker without polling.

https://www.reddit.com/r/tasker/comments/3y3kpx/how_to_query_tasker_if_the_screen_is_locked_or_not/ has a solution that polls.
Create a profile Screen Locked triggered on the event Display Off and calling a task that sets a variable %SCREEN_LOCKED to true iff %SCREEN is off.

Create another profile Screen Unlocked triggered on the event Display Unlocked and calling a task that sets that variable to false.

If you'd like for a profile to be triggered (or not) if the screen is locked:
Create a third profile Display Locked triggered on the variable being true  and calling some NoOp task (which does pretty much nothing) then use the Profile Active trigger on the profile conditional on screen lock state.