Results 1 to 6 of 6

Thread: Find an allready running instances of a thread and connect to it

  1. #1
    Join Date
    Apr 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Find an allready running instances of a thread and connect to it

    Is it possible to to search for an allreay running instance of for example a thread and ''connect'' to it?
    Something like this:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. MainWindow w;
    5. w.show();
    6. wnThread *th = find(wnThread);
    7. if(th = NULL){
    8. wnThread *th = new wnThread();
    9. th->start();
    10. }
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 
    I know about dde in Windows but i need a solution for independent operatingsystems.

    Thanks

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Find an allready running instances of a thread and connect to it

    No, not that I know of.

    You have a simple problem, though. Use a factory to make all your threads and then you will only need a very simple observer mechanism to obtain knowledge of the running state of all threads.


    Can I put it to you that your question is not a 'good' one, though? By that I mean you are asking

    'I want to do X (because I think it is a solution to my problem). How do I do it?',

    but you would probably be better of asking

    'My problem is Y, what is a good way to solve it?'
    Last edited by amleto; 12th November 2012 at 19:24.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Apr 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Find an allready running instances of a thread and connect to it

    Quote Originally Posted by amleto View Post
    No, not that I know of.

    You have a simple problem, though. Use a factory to make all your threads and then you will only need a very simple observer mechanism to obtain knowledge of the running state of all threads.


    Can I put it to you that your question is not a 'good' one, though? By that I mean you are asking

    'I want to do X (because I think it is a solution to my problem). How do I do it?',

    but you would probably be better of asking

    'My problem is Y, what is a good way to solve it?'
    Ok will try the other way round:
    I've got a Hardware-Device which can be attached to the computer. So far so good, but its driver just let me communicate by one programm. Since I'd like to process data from the device by two or even more programms simultaneously it would be great to have somekind of data-exchange programm. Hope you understand me.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Find an allready running instances of a thread and connect to it

    ok, so you want a server to fork the data. Networking's not really my thing, but I don't see where are the threads come in. You'll just be reading data from your device socket, and then posting it on multiple sockets for your other apps.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Apr 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Find an allready running instances of a thread and connect to it

    Quote Originally Posted by amleto View Post
    ok, so you want a server to fork the data. Networking's not really my thing, but I don't see where are the threads come in. You'll just be reading data from your device socket, and then posting it on multiple sockets for your other apps.
    Well its not quiet a Server its more an eeprom attached via usb. Its data is needed in sever applications. So the question is how to build a "Software-sever" that can be connected by an other Software.

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Find an allready running instances of a thread and connect to it

    use sockets/networking classes in Qt. It is a well-trodden path, and it won't need any 'funny business' searching for zombie/daemon/headless threads
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QThread not running in different thread
    By lauwe in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2011, 23:02
  2. Replies: 7
    Last Post: 4th June 2010, 14:52
  3. how to terminate a thread when it is running
    By guchangyuan in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2009, 10:50
  4. running() - Thread
    By sabeesh in forum Qt Programming
    Replies: 5
    Last Post: 9th October 2007, 18:45
  5. QThread: Destroyed while thread is still running
    By Shuchi Agrawal in forum Newbie
    Replies: 8
    Last Post: 3rd April 2007, 06:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.