How can I let my app update itself programmatically?

I want to update the app resources and binaries from inside the app itself.