somu0915
March 3rd, 2008, 02:53 AM
I am new to threading concepts in C++/CLI.
I have a button and a label in the form and here is some code for that:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Form1^ f = gcnew Form1;
Thread^ myThread = gcnew Thread(gcnew ThreadStart(f, &Form1::test));
myThread->Start();
}
void test()
{
this->label1->Text = "Hi";
this->label1->Update();
}
But this code dosent update the Label.. WHY???
I have also used [MTAThreadAttribute] in my main file as:
[MTAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
Somebody please help..
I have a button and a label in the form and here is some code for that:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Form1^ f = gcnew Form1;
Thread^ myThread = gcnew Thread(gcnew ThreadStart(f, &Form1::test));
myThread->Start();
}
void test()
{
this->label1->Text = "Hi";
this->label1->Update();
}
But this code dosent update the Label.. WHY???
I have also used [MTAThreadAttribute] in my main file as:
[MTAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
Somebody please help..