Create Thread in Business Logic
I have an afterCreate event handler in my business logic that is synchronous. It needs to be synchronous as I have several tasks that need to be completed before sending the response to the user. BUT, there are also several tasks in the afterCreate that I'd like to do asynchronously (for instance sending an email or push notification can sometimes take a while).
1) What is the appropriate way to accomplish this? I don't think just creating a new Thread() is going work will it?
2) Are there any scenarios where an error could occur between when beforeCreate is called and the object is actually created in the data table? I ask this because if it is an extremely small possibility that an error can occur there, then I might move my synchronous tasks in the afterCreate over to the beforeCreate instead (I have it in afterCreate so I can ensure my updates are synched properly).