About threads and forms...
-
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.
-
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.
You must invoke methods from other threads, instead of calling them directly. DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET
-
You must invoke methods from other threads, instead of calling them directly. DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET
-
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.
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
-
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
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.
-
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.
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