I invented a new software based hardware technology which can solve many problems. I know getting a patent takes a very long time and is not an easy task.
Do I have to apply and wait to get a patent before I release my technology? (Even preparing to apply takes a lot of time/money, and approval takes forever.) Or is there some way to publish my technology faster and safely before getting a patent without losing inverter's rights? Or is the only legal way to protect my right for this technology by getting a patent before publishing it on the Internet?
I'm not in the US.
You can file for a provisional patent, that gives you the patent rights while allowing you publishing the invention. You need to file for a patent within a year. Provisional patent is a very informal filing, but you need to word it carefully not to omit any of your potential patent claims while still not making it too broad to be disqualified.
Once you filed for a patent/provisional, you can disclose your invention. You're not required to keep it secret while the patent is still pending.
Generally this kind of questions should be addressed by patent attorneys, or legal advisers.
To protect your right to patent something, you should file the patent before you publicly disclose or sell the technology. This is a strict limitation in many countries.
The U.S. is more lenient in this respect in that you can file your patent application up to one year after disclosure/sale of the technology. The U.S., however, is in the process of switching to a "first to file" system so you should file ASAP so that someone else doesn't file a similar invention before you do.
Notwithstanding the above, you don't absolutely need a patent. A patent doesn't give you the right to sell your product, it just gives you the right to prevent others from practicing your invention. The primary purpose of a patent is to prevent others from copying your invention. This is a somewhat subtle but important distinction.
Also, even if you have a patent that covers your technology, it is still possible that you are infringing someone else's patent.
You could always make a poor man's patent. It is less protective, but at least it is something.
Print out your idea, plan, and code, seal it, and mail it to yourself. It will be time-stamped. That way, you have proof that you created it before a certain time.