There are several ways how to toggle hidden files - via a shell command, or AppleScript, or Automator action, or even a Dashboard widget. All of them close and reopen Finder windows, which is quite annoying.
On the other hand, for the Open File dialog one can easily toggle hidden files by pressing
Is it possible to avoid relaunching Finder?
It is better to use Path Finder instead, which allows not only to toggle hidden files without a perversion, but many other nice things. Really awesome app.