#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    6
    Rep Power
    0

    Solution required


    I have a situation as following. I want to run a program in the background. then display a message box that process is running. i want to give user an option, like Cancel button, to terminate the process. But i am running the process in some thread. And threads can not be killed. So Please help me about how i should do that Canceling thing.

    Please, its urgent

    Thanks
    Vikram Karandikar
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    A thread is a function that runs in the background, and the thread terminates when the function ends. So all you need to do is to return from the function.

    I presume the dialog box is non-modal, since displaying a modal dialog will stop the thread from doing its thing. I suggest having a boolean flag somewhere that the dialog sets to True when the user clicks Cancel, and the thread function checks this flag at regular intervals and returns when it is True.

    What GUI library are you using? If it is wxPython then there are issues with using the GUI from outside of the main thread. You may find this page useful: http://wiki.wxpython.org/index.cgi/LongRunningTasks

    There may be similar issues with Tkinter, but it has been a while since I have used it so I can't say for sure.

    Dave - The Developers' Coach
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    6
    Rep Power
    0
    Thank you for your quick reply. I am using wxPython, and that was the my next question, why its not working. But any ways, i will read the page and will find the way out. Again thanks

    Vikram Karandikar

IMN logo majestic logo threadwatch logo seochat tools logo