threading problem
-
i am working on a project which has two form. i want to run the second form in a different thread. and i declared my thread
private: System::Threading::Thread^ MyThread;
andthis->myThread = (gcnew System::Threading::Thread( gcnew System::Threading::ThreadStart( &MyClass::MyFunction)));
and i added"this->MyThread ->Start();
into button1_Click decleration and i include the form2 into my form1 header file and added my class codes under under the Form2's codes so far everything is ok, but when i debug my project form2 can open once and after i close Form2, it doesnt open again, when i tried to click the button an error occours "Thread is running or terminated" How can i run my thread again after i close it?--always comes daylight after night-----
-
i am working on a project which has two form. i want to run the second form in a different thread. and i declared my thread
private: System::Threading::Thread^ MyThread;
andthis->myThread = (gcnew System::Threading::Thread( gcnew System::Threading::ThreadStart( &MyClass::MyFunction)));
and i added"this->MyThread ->Start();
into button1_Click decleration and i include the form2 into my form1 header file and added my class codes under under the Form2's codes so far everything is ok, but when i debug my project form2 can open once and after i close Form2, it doesnt open again, when i tried to click the button an error occours "Thread is running or terminated" How can i run my thread again after i close it?--always comes daylight after night-----
-
because, the second form will start a process ,and the process can be stopped and the 2nd form will be closed if it is neccessary. as far as i know, there is no way else to stop a process but using threads. is there?
--always comes daylight after night-----
-
because, the second form will start a process ,and the process can be stopped and the 2nd form will be closed if it is neccessary. as far as i know, there is no way else to stop a process but using threads. is there?
--always comes daylight after night-----
Adnan Merter wrote:
as far as i know, there is no way else to stop a process but using threads. is there?
yes you can use a message pump but threads are normally a better solution.
Adnan Merter wrote:
i want to run the second form in a different thread.
Did you look at the BackgroundWorker class[^]?
led mike