I have been trying to figure out how to create a thread in VC++ .net that will be able to do the job of updating my Windows Form.
For example, this is my current windows form created by VC++ :
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public __gc class Form1 : public System::Windows::Forms::Form
void Dispose(Boolean disposing)
if (disposing && components)
private: System::Windows::Forms::ListBox * listBox1;
System::ComponentModel::Container * components;
this->listBox1 = new System::Windows::Forms::ListBox();
System::Object* __mcTemp__1 = new System::Object*;
__mcTemp__1 = S"firstElement";
this->listBox1->Location = System::Drawing::Point(16, 24);
this->listBox1->Name = S"listBox1";
this->listBox1->Size = System::Drawing::Size(272, 173);
this->listBox1->TabIndex = 0;
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(448, 349);
this->Name = S"Form1";
this->Text = S"Form1";
What I want to do is that, I want to create a thread that will be able to update the listBox1 while not freezing up the windows form. I have tried using __beginthread but it seems that the compiler does not like that for some reason..
Has anyone done something simliar and can tell me what kind of thread i should use here so that I can update the listBox1 WITHIN the thread.
And, how do I pass the "System::Object* __mcTemp__1" pointer? The inline declaration is really confusing me.
Is there a way I can just update the listBox1 the same way as if i were doing it in C#?? (ie, listBox1.Items.Add...)
I am going to put a 500 points on this question because i have been looking around and testing for a while without any luck.. I hope someone can give me some hint or direction on how to complete this task.