Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. threading problem

threading problem

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestiondebugging
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adnan Merter
    wrote on last edited by
    #1

    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; and this->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-----

    L 1 Reply Last reply
    0
    • A Adnan Merter

      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; and this->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-----

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Adnan Merter wrote:

      i want to run the second form in a different thread.

      Why?

      led mike

      A 1 Reply Last reply
      0
      • L led mike

        Adnan Merter wrote:

        i want to run the second form in a different thread.

        Why?

        led mike

        A Offline
        A Offline
        Adnan Merter
        wrote on last edited by
        #3

        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-----

        L 1 Reply Last reply
        0
        • A Adnan Merter

          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-----

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups