开发者

Initialize a managed array of thread

开发者 https://www.devze.com 2023-02-18 10:41 出处:网络
I have success to compile the following code but I have to make an array of thread out of it. Form1^ form1obj = gcnew Form1();

I have success to compile the following code but I have to make an array of thread out of it.

Form1^ form1obj = gcnew Form1();
Thread^ bfcaller = gcnew Thread(
gc开发者_Python百科new ThreadStart(  form1obj, &Form1::bruteforce  ));
bfcaller->Start();

I got errors by the making it array like this:

array<Form1^>^ form1obj = gcnew array<Form1^>(25);
array<Thread^>^ bfcaller = gcnew array<Thread^>[25];

for (int counter = 0; counter < 25; counter++)
{
    bfcaller[counter] = gcnew Thread( gcnew ThreadStart(form1obj, &Form1::bruteforce));
}

Where do I did it wrong? Thanks for help.


Several syntax mistakes in your code.

   gcnew array<Thread^>[25];

Don't use square brackets, use (25)

   gcnew ThreadStart(form1obj, &Form1::bruteforce)

First argument is wrong, it must be a reference to a Form1 instance, not an array of forms since bruteforce() is a method of Form1. Maybe you meant form1obj[counter].

0

精彩评论

暂无评论...
验证码 换一张
取 消