add helper funcion to invoke a function in gl thread