It depends on the size of the task. A task of 30 minutes to 3 hours is not that bad to ask of a candidate, depending on circumstances.
But I saw a recent job offer on a HN "Who's hiring?" which came with a programming challenge. Once I read it, I realized it might take several hours to get it all done, and they said "add even more to impress us!"
Well, I'm full-time, as are a lot of good candidates. I don't have time to mess with this. Normally I like small software development challenges, as I like software development.
And, y'know, if I was unemployed, I would pour a bunch of time into this. The very worst case is that I learn and practice new things, and I would want to stand out from the pack.
But since I'm employed, I don't have time to spend 5+ hours on a project where the employer has not put in any effort of their own.
I found a news article about the company where they said they would get 600 resumes for a posting and set up challenges as a filter. I think they went way to far in the other direction.