Developing OpenCL wrapper with proper events to avoid runtime crash