我试图使用backgroundworker更改mu UI控件。我读到了Control-> Invoke()类,但我不知道如何在C ++中使用它。 这就是我得到的:
System::Void check_new() {
p = ((Label^)napisy[IdNadawca])->Location;
System::Windows::Forms::PictureBox^ pb = (gcnew System::Windows::Forms::PictureBox());
koperty[System::Convert::ToInt32(((Label^)napisy[IdNadawca])->Name)] = pb;
pb->Location = System::Drawing::Point(p);
pb->Left = 755;
pb->Name = (System::Convert::ToString(IdNadawca));
pb->Size = System::Drawing::Size(30, 20);
pb->TabIndex = 2;
pb->TabStop = false;
pb->Image= (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"koperta_mala")));
Controls->Add(pb);
}
此功能(由backgroundworker调用)在UI中创建一个图片框。 问题是,我不知道如何使用后台线程访问UI。