c++ - In wxwidgets, how do I make one thread wait for another to complete before proceeding? -


I have a system where my singleton class has produced a thread to calculate. If the user requests another calculation, while another calculation is still going on, I want to tear the current thread and start a new one. But, before moving forward, it should first wait for the thread to complete the exit. Everything is broken by working to me, but I think there is an issue to ensure that only one thread runs. My approach is to call for the StartCalculation function mutex-> Lock (). And releases thread lock in the disaster, it is not working. Am I right to assume that if lock (lock) can not be found, then it is a spin and trying to regain the lock? Can this lock () be called from my main application thread? Any idea is useful, maybe wxMutex locks are the right mechanism for this.

To wait for a thread, you need to make it editable and simply Use wxThread :: Wait () . Although I agree with the comment given above: It is not something you normally do and definitely do not do with the main GUI thread because you should never block it because it freeze the UI.

Tell the current task about the new work that needs to be done instead.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -