开发者

Initialize a managed array of thread

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜