Funny, I run into the exact same problem on the exact same platform. It's what I dislike most about working in .NET.
One thing I've found that works fairly well is using the Pomodoro technique, where I force myself for 25 minutes to just work. That means even during those 15-30 seconds of compiling I can't load up Hacker News or Reddit. It helps, but it's also a little tough for me to enforce (on myself).