Custom Abort() method for aborting foreground update check added

This commit is contained in:
Simon Rozman 2016-06-02 20:29:33 +02:00
parent 7271221bd4
commit 55548e1059
2 changed files with 21 additions and 0 deletions

View File

@ -67,6 +67,14 @@ public:
return DoCheckForUpdate(); return DoCheckForUpdate();
} }
///
/// Aborts current update check
///
inline void Abort()
{
m_abort = true;
}
protected: protected:
/// ///
/// Thread's body /// Thread's body
@ -75,6 +83,11 @@ protected:
/// ///
virtual ExitCode Entry(); 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. /// Checks for updates and safely downloads update package when available.
/// ///
@ -140,6 +153,7 @@ public:
protected: protected:
wxEvtHandler *m_parent; ///< Parent to notify wxEvtHandler *m_parent; ///< Parent to notify
bool m_ok; ///< Is class initialized correctly? bool m_ok; ///< Is class initialized correctly?
volatile bool m_abort; ///< Should Update check abort?
wxString m_langId; ///< Language identifier wxString m_langId; ///< Language identifier
wxConfig m_config; ///< Application configuration wxConfig m_config; ///< Application configuration

View File

@ -32,6 +32,7 @@ wxDEFINE_EVENT(wxEVT_UPDATER_CHECK_COMPLETE, wxThreadEvent);
wxUpdCheckThread::wxUpdCheckThread(const wxString &langId, wxEvtHandler *parent) : wxUpdCheckThread::wxUpdCheckThread(const wxString &langId, wxEvtHandler *parent) :
m_parent(parent), m_parent(parent),
m_abort(false),
m_langId(langId), m_langId(langId),
m_config(wxT(UPDATER_CFG_APPLICATION) wxT("\\Updater"), wxT(UPDATER_CFG_VENDOR)), m_config(wxT(UPDATER_CFG_APPLICATION) wxT("\\Updater"), wxT(UPDATER_CFG_VENDOR)),
m_cs(NULL), m_cs(NULL),
@ -85,6 +86,12 @@ wxThread::ExitCode wxUpdCheckThread::Entry()
} }
bool wxUpdCheckThread::TestDestroy()
{
return m_abort || wxThread::TestDestroy();
}
wxUpdCheckThread::wxResult wxUpdCheckThread::DoCheckForUpdate() wxUpdCheckThread::wxResult wxUpdCheckThread::DoCheckForUpdate()
{ {
if (!m_ok) if (!m_ok)