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. C#
  4. About threads and forms...

About threads and forms...

Scheduled Pinned Locked Moved C#
questionmobiledatabasedesignxml
6 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.
  • G Offline
    G Offline
    GriffonRL
    wrote on last edited by
    #1

    Hello, I wrote a program who is not UI dependent. I have all my program logic in a class and I raise some events for any potential frontend. I can then create a console application or a Windows form application using the same program logic. The frontend just run a thread using the run() function of my main class (UI independent) which do all the job. This main class also creates internally several threads performing various tasks in parallel. Since all this threads are just pure computation I have no problems. But I recently wanted to create forms in some of these internal threads running in parallel and I have been unsuccessful for far :(. What happens is that forms get created but are not responsive at all and the internal threads get stuck. How can I create these forms and make them run independently in each thread ? Here is schema: Frontend (Console or Form, main thread) | | Main class (running in a thread) | | | | | | | | | | Child threads (computation) x x x x x <-- child threads can not work with forms x x x x x <-- how to call functions in those forms ? Child threads forms Any idea ? R. LOPES Just programmer.

    L 1 Reply Last reply
    0
    • G GriffonRL

      Hello, I wrote a program who is not UI dependent. I have all my program logic in a class and I raise some events for any potential frontend. I can then create a console application or a Windows form application using the same program logic. The frontend just run a thread using the run() function of my main class (UI independent) which do all the job. This main class also creates internally several threads performing various tasks in parallel. Since all this threads are just pure computation I have no problems. But I recently wanted to create forms in some of these internal threads running in parallel and I have been unsuccessful for far :(. What happens is that forms get created but are not responsive at all and the internal threads get stuck. How can I create these forms and make them run independently in each thread ? Here is schema: Frontend (Console or Form, main thread) | | Main class (running in a thread) | | | | | | | | | | Child threads (computation) x x x x x <-- child threads can not work with forms x x x x x <-- how to call functions in those forms ? Child threads forms Any idea ? R. LOPES Just programmer.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      You must invoke methods from other threads, instead of calling them directly. DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

      G 1 Reply Last reply
      0
      • L leppie

        You must invoke methods from other threads, instead of calling them directly. DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

        G Offline
        G Offline
        GriffonRL
        wrote on last edited by
        #3

        Hello, I understood I have to use invoke from threads to call methods in controls. But what about creating forms from threads ? Thanks, R. LOPES Just programmer.

        L 1 Reply Last reply
        0
        • G GriffonRL

          Hello, I understood I have to use invoke from threads to call methods in controls. But what about creating forms from threads ? Thanks, R. LOPES Just programmer.

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          GriffonRL wrote: But what about creating forms from threads ? ???? :eek: What are you trying to do? I would keep my whole UI in one thread (the main one preferably). DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

          G 1 Reply Last reply
          0
          • L leppie

            GriffonRL wrote: But what about creating forms from threads ? ???? :eek: What are you trying to do? I would keep my whole UI in one thread (the main one preferably). DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

            G Offline
            G Offline
            GriffonRL
            wrote on last edited by
            #5

            Hi, My goal is to have several forms running independently. Each form has its own thread doing a specific computation. One example could be to have several forms embedding the webbrowser control and automatically crawling a different website. All will run in parrallel. Any idea ? R. LOPES Just programmer.

            L 1 Reply Last reply
            0
            • G GriffonRL

              Hi, My goal is to have several forms running independently. Each form has its own thread doing a specific computation. One example could be to have several forms embedding the webbrowser control and automatically crawling a different website. All will run in parrallel. Any idea ? R. LOPES Just programmer.

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              GriffonRL wrote: Any idea ? I would STILL keep all the controls on one thread, but make them child form (usercontrols rather). I suggest you use something like the Magic Library's DockingManager as the hosting windows can easily move outside the form area or hidden. DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

              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