diff --git a/Updater/include/Updater/chkthread.h b/Updater/include/Updater/chkthread.h index 794b54b..617c573 100644 --- a/Updater/include/Updater/chkthread.h +++ b/Updater/include/Updater/chkthread.h @@ -67,6 +67,14 @@ public: return DoCheckForUpdate(); } + /// + /// Aborts current update check + /// + inline void Abort() + { + m_abort = true; + } + protected: /// /// Thread's body @@ -75,6 +83,11 @@ protected: /// virtual ExitCode Entry(); + /// + /// Overrriden method to allow custom termination when Updater is launched in the main thread. + /// + virtual bool TestDestroy(); + /// /// Checks for updates and safely downloads update package when available. /// @@ -140,6 +153,7 @@ public: protected: wxEvtHandler *m_parent; ///< Parent to notify bool m_ok; ///< Is class initialized correctly? + volatile bool m_abort; ///< Should Update check abort? wxString m_langId; ///< Language identifier wxConfig m_config; ///< Application configuration diff --git a/Updater/src/chkthread.cpp b/Updater/src/chkthread.cpp index 01980f8..2445992 100644 --- a/Updater/src/chkthread.cpp +++ b/Updater/src/chkthread.cpp @@ -32,6 +32,7 @@ wxDEFINE_EVENT(wxEVT_UPDATER_CHECK_COMPLETE, wxThreadEvent); wxUpdCheckThread::wxUpdCheckThread(const wxString &langId, wxEvtHandler *parent) : m_parent(parent), + m_abort(false), m_langId(langId), m_config(wxT(UPDATER_CFG_APPLICATION) wxT("\\Updater"), wxT(UPDATER_CFG_VENDOR)), m_cs(NULL), @@ -85,6 +86,12 @@ wxThread::ExitCode wxUpdCheckThread::Entry() } +bool wxUpdCheckThread::TestDestroy() +{ + return m_abort || wxThread::TestDestroy(); +} + + wxUpdCheckThread::wxResult wxUpdCheckThread::DoCheckForUpdate() { if (!m_ok)