summaryrefslogtreecommitdiff
path: root/library/multithreading.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 16:53:07 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 16:53:07 +0200
commit583d6a1fd6701e3d42c87285265b0b4f7657ab7c (patch)
tree78461dd1a74685252eef77b8e7d3b622d1be67ea /library/multithreading.cpp
parent1.9 (diff)
downloadFreeFileSync-583d6a1fd6701e3d42c87285265b0b4f7657ab7c.tar.gz
FreeFileSync-583d6a1fd6701e3d42c87285265b0b4f7657ab7c.tar.bz2
FreeFileSync-583d6a1fd6701e3d42c87285265b0b4f7657ab7c.zip
1.10
Diffstat (limited to 'library/multithreading.cpp')
-rw-r--r--library/multithreading.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/library/multithreading.cpp b/library/multithreading.cpp
index 19f83b94..78077f1e 100644
--- a/library/multithreading.cpp
+++ b/library/multithreading.cpp
@@ -1,8 +1,36 @@
#include "multithreading.h"
#include <wx/utils.h>
+#include <wx/app.h>
+#include <wx/timer.h>
+
//#include "windows.h"
//MessageBox(0, "hi", "", 0);
+void updateUiNow()
+{
+ //process UI events and prevent application from "not responding" -> NO performance issue!
+ wxTheApp->Yield();
+
+ // while (wxTheApp->Pending())
+ // wxTheApp->Dispatch();
+}
+
+
+bool updateUiIsAllowed()
+{
+ static wxLongLong lastExec = 0;
+
+ wxLongLong newExec = wxGetLocalTimeMillis();
+
+ if (newExec - lastExec >= UI_UPDATE_INTERVAL) //perform ui updates not more often than necessary
+ {
+ lastExec = newExec;
+ return true;
+ }
+ return false;
+}
+
+
/*choreography:
------------- ---------------
@@ -149,10 +177,10 @@ void UpdateWhileExecuting::execute(StatusUpdater* statusUpdater)
while (receivingResult.WaitTimeout(UI_UPDATE_INTERVAL) == wxCOND_TIMEOUT)
{
- statusUpdater->triggerUI_Refresh(true); //ATTENTION: Exception "AbortThisProcess" may be thrown here!!!
+ statusUpdater->requestUiRefresh(true); //ATTENTION: Exception "AbortThisProcess" may be thrown here!!!
if (workDone == true) //workaround for a bug in wxWidgets v2.8.9 class wxCondition: signals might get lost
- break; //no mutex for workDone needed here: it is changed only when maintread is in WaitTimeout()
+ break; //no mutex for workDone needed here: it is changed only when mainthread is in WaitTimeout()
}
}
bgstack15