I'm trying to use the main_thread_callback_manager to setup a method to notify components of changes in the variables provided by cwb_hooks. But when I do what I think is the correct way, the callback_run method isnt called until I exit foobar2000. Below is a stripped down version of what I am doing. The messageboxes only popup after I exit foobar2000. If I cheat and just call p_callback->callback_run directly rather than add the callback to the manager, it works, so it appears the var_notify_callback is created correctly.
any help is appreciated.
CODE
class var_notify_callback : public main_thread_callback
{
public:
pfc::string8_fastalloc m_var;
var_notify_callback( const char * var )
{
m_var = var;
}
virtual void callback_run()
{
uMessageBox( NULL, "w00t", "w00t", MB_OK );
}
};
void post_callback_notification( const char * str )
{
service_ptr_t<var_notify_callback> p_callback = new service_impl_t<var_notify_callback>( str );
static_api_ptr_t<main_thread_callback_manager> man;
man->add_callback( p_callback );
}