c++ - unmanaged class method: non-standard syntax; use '&' to create a pointer to member -


i'd run, in managed thread, method unmanaged class, , got confused, being neophyte clr.

#include <boost/asio/io_service.hpp> using namespace system::threading;  public ref class managedclass;  int main() {     managedclass^ managedobject = gcnew managedclass();      thread^ threadok = gcnew thread(                          gcnew threadstart(                            managedobject,                            &managedclass::run));       boost::asio::io_service unmanagedobject;      thread^ threadwrong = gcnew thread(                             gcnew threadstart(                               unmanagedobject,                               &boost::asio::io_service::run)); } 

because, obviously,

invalid delegate initializer -- function not member of managed class

so started googling managed threads on unmanaged code found nothing clarifying. advice? on wrong way?

as ukmonkey said, little boilerplate sufficient...

public ref class cmystartservice {     boost::asio::io_service * _pioservice;  public:     cmystartservice(boost::asio::io_service * pioservice) :         _pioservice(pioservice)     {     }      void run()     {         _pioservice->run();     } };  // in main  cmystartservice^ cmystartservice = gcnew cmystartservice(&ioservice); thread^ thread_io_service = gcnew thread(                                gcnew threadstart(                                 cmystartservice, &cmystartservice::run)); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -