2017-05-29 79 views
-6
Parallel.For(<your starting value >,<End criteria for loop>, delegate(int < your variable Name>) 
{ 
    // Your own code 
});  

ここでは、C#でいくつかのサンプルコードを示しています。私はC++/CLIで同様の機能を望みますが、この表現の使い方はわかりません: "delegate(int <あなたの変数名>)"。C++/cliの並列forループ

+0

[ 'のstd :: for_each'(http://en.cppreference.com/w/cpp/algorithm/for_each)と今後のC++の 'parallel_policy' [実行ポリシー](http://en.cppreference.com/w/cpp/algorithm/execution_policy_tag_t) 17標準はそれを行うことができるはずです。 –

+6

何があなたを止めていますか? 'Parallel.For'は* managed * C++で利用可能です。 –

+2

Windows/VisualStudioの場合、Concurrency :: parallel_forを試してください – yms

答えて

0

あなたがC++ CLIを使用している場合System.Threading.Tasks.Parallelが

例通常の.NET Frameworkのクラスであることから、その後、あなたがC#であなたが使用するのと同じParallel.Forを使用することができるはずです(さえコンパイルされていない、テストされていない):

ref class SomeClass 
{ 
public: 
    static void Func(int index) 
    { 
     Console::WriteLine("Test {0}", index); 
    } 
}; 

delegate void MyCallback(int index); 

int main() 
{ 
    MyCallback^ callback = gcnew MyCallback(SomeClass::Func);  
    Parallel.For(0, 9, callback); 
} 

関連:How to: Define and Use Delegates in C++/CLI

関連する問題