|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Solution required |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|