Run asynchronous file dialog in new thread on Windows

This makes our file dialog API real asynchronous on Windows, and fixes #802.