473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Pausing Threads?

I have created a program with a gui that uses threads to accomplish it's task, what I was wondering was is how the 'pause' effect can be accomplished in python?

so here's what I want to accomplish:
They push the pause button, and all threads stop what they're doing. The threads also should be able to resume upon the user's request.
May 23 '07 #1
6 1668
bartonc
6,596 Expert 4TB
I have created a program with a gui that uses threads to accomplish it's task, what I was wondering was is how the 'pause' effect can be accomplished in python?

so here's what I want to accomplish:
They push the pause button, and all threads stop what they're doing. The threads also should be able to resume upon the user's request.
The simplest (and one of the few thread-safe ways) way is to use an threading.Event object shared by the main thread and the worker thread. By using (say) pauseEvent.set() in the main thread and eventPassedInThreadArgsEvent.isSet() in the worker, you can control the thread's behavior.

Ps: sorry for the late reply. Yesterday was quite hectic and today I finally got my new SOHO network up to speed.

Thanks for joining (and the comment in the Articles Section).
May 24 '07 #2
bartonc
6,596 Expert 4TB
Is "Sardonic" like sarcastic, only different?
May 25 '07 #3
Thank you for your help ^_^

"Derived from the Greek Sardonios which means bitter or scornful laughter: the primary reference is to the effects of eating a Sardinian plant which was said to produce facial convulsions resembling horrible laughter, usually followed by death."
~_~
Jun 2 '07 #4
bartonc
6,596 Expert 4TB
Thank you for your help ^_^

"Derived from the Greek Sardonios which means bitter or scornful laughter: the primary reference is to the effects of eating a Sardinian plant which was said to produce facial convulsions resembling horrible laughter, usually followed by death."
~_~
VERY interesting. Thanks for sharing.
Have you got any working code that you'd like to share with our members who may come up against the same type of problem?
Jun 2 '07 #5
VERY interesting. Thanks for sharing.
Have you got any working code that you'd like to share with our members who may come up against the same type of problem?
not quite yet, i'm still trying to figure it out myself. I'll post the program I'm currently working on (it's my first real program in any language, so you can imagine how gruesome it'll be ^_^).
Jun 4 '07 #6
bartonc
6,596 Expert 4TB
not quite yet, i'm still trying to figure it out myself. I'll post the program I'm currently working on (it's my first real program in any language, so you can imagine how gruesome it'll be ^_^).
By all means, we're here to help with any stage of development!
A multi-threaded program is a huge chunk to bite into for a beginner. Luckily, Python is quite a forgiving language in that regard.
Have fun and keep posting,
Barton
Jun 4 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Simon John | last post by:
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin, that on connection receives a track length. To save on bandwidth, I don't want to be continually querying the server for...
7
by: Dr. Know | last post by:
I am working on an ASP page that writes to several databases, ranging from MDBs to x-base. One of the tasks involves using an existing highest value from the DB and incrementing it before...
7
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
2
by: BLUE | last post by:
I would like to pause an application while the GUI display a Label saying "Logging in...". System.Timers System.Windows.Forms.Timer System.Threading.Timer System.Threading ==Thread.Sleep ...
0
by: Grayzag | last post by:
Hi there, As part of my Software course, i have to create a game. Since I originally started out with python, I was used to it being really easy to create a main loop to control the game with a...
12
by: greg | last post by:
Hi, Can anyone help me with the following issue: How can I pause the execution of a program until a given file is created (by another process) in a specified directory? Any ideas would be...
1
by: John | last post by:
Hi I need to add pauses in-between processes in my app to give time to other users/processes on the network. Is there a way to pass control to OS for a specified time (say 15 seconds) to delay...
3
by: Lucress Carol | last post by:
Hi everyone, I'm having troubles with pausing and continuing MFC Thread.For test purposes I've created in my MFC Dialog application a progress Bar Control, a Start Button and a Stop Button.The...
0
by: thesti | last post by:
hello, i have some jbuttons in my frame. and i have a recursive method, which will check a certain condition and if satisfied, will move one of the jbuttons location to somewhere else in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.