There is a CommandProperty that is rendered as a button in the edit interface.
The CommandProperty has two relevant settings:
"Method name" and "Use Command Workflow"
Method name is the name of the method on the partial class that should invoke when the button is clicked.
"Use Command workflow" determines if the method should be run as part of the request in edit, or if it should be started from a workflow. If started from workflow, it runs in a separate thread, so it will run in the background.
The drawback is that it can't access the web context if you need to access information from the web context.
For the ultimate in flexibility, choose to run it in web context, but start a workflow from within the method. Set properties on the workflow object to give the workflow the information it needs from the web context.
Let me know if you want more detailed instructions.