Visual C++ General
Some of operations on controls can be performed only by threads that created the controls. In case of multithreading you should apply approaches described in "How to: Make Thread-Safe Calls to Windows Forms Controls" article [http://msdn2.microsoft.com/en-us/library/ms171728.aspx].
Translated to C++ and Visual Studio 2005, you have to execute something like this. Instead of
label->Text = "some text";
you have to add a delegate and a function:
class Form1
{
. . .
delegate void SetTextDelegate(System:: String ^ s);
void SetText(System:: String ^ s)
{
label->Text = s;
}
. . .
};
Then, in your background thread, set the label¡¯s text like this:
array< System:: Object^ > params = { "some text" };
Invoke(gcnew SetTextDelegate(this, &Form1:: SetText), params);
I hope this works.