And the mechanism for appreciation on Stack Overflow is not thanks. It's +1 votes and selected answers. Those appreciate mechanisms drive the site and ensure the person who helped you helps many other people.
And there is no reason to remove that social lubrication because you're of a different opinion. If they're not doing the +1 and selected answer, then tell them to, but don't stop them from being decent human beings as well, even if you'd prefer the world that way.
Leave a comment, then delete it after you're confident the recipient will have seen it. (A few hours or days depending on activity.) You and they get to feel good, but the clutter isn't left around for other users.
This is what I often do. It is a tolerated behaviour, even if some people aren't thrilled with it.
I give my thanks through comments. I think that makes sense given their model -- the question and answer are the straightforward facts about the problem intended for future googlers and posterity. The comments are little meta-data intended for the asker and answerers.