Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ParameterizedThreadStart,c++/cli_C++_Multithreading_Command Line Interface - Fatal编程技术网

C++ ParameterizedThreadStart,c++/cli

C++ ParameterizedThreadStart,c++/cli,c++,multithreading,command-line-interface,C++,Multithreading,Command Line Interface,使用ParameterizedThreadStart(System::Threading)允许传递调用函数的参数。但是声明此参数的对象类型并不舒服。有没有办法指定此类参数的确切类型?如何在该函数中传递多个参数?只需声明一个具有所需属性的小助手类,并将其实例作为参数传递。使用safe_Cast将其从Object^中的线程方法转换回您的助手类。@Hans Passant谢谢!但是我在使用这段代码时遇到了一个错误:void myfunc(Object^obj){hh=safe_cast(obj);Co

使用ParameterizedThreadStart(System::Threading)允许传递调用函数的参数。但是声明此参数的对象类型并不舒服。有没有办法指定此类参数的确切类型?如何在该函数中传递多个参数?

只需声明一个具有所需属性的小助手类,并将其实例作为参数传递。使用safe_Cast将其从Object^中的线程方法转换回您的助手类。@Hans Passant谢谢!但是我在使用这段代码时遇到了一个错误:void myfunc(Object^obj){hh=safe_cast(obj);Console::WriteLine(“{0}{1}{2}”,hh->a,hh->b,hh->c);}“对象引用未设置为对象的实例。”(inta,b,c从helper构造函数接收)