From 5f4f5b58f6557eedf795696cca090e2308f329a9 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Mon, 4 Oct 2004 10:51:11 +0000
Subject: [PATCH] added wxApp::IsMainLoopRunnning() (see bug 994293)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29645 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/app.tex | 12 ++++++++++++
 include/wx/app.h      | 11 +++++++++++
 2 files changed, 23 insertions(+)

diff --git a/docs/latex/wx/app.tex b/docs/latex/wx/app.tex
index 3606ab231b..c0a89645af 100644
--- a/docs/latex/wx/app.tex
+++ b/docs/latex/wx/app.tex
@@ -207,6 +207,18 @@ attract users attention to the application, you may use
 to do it.
 
 
+\membersection{wxApp::IsMainLoopRunning}\label{wxappismainlooprunning}
+
+\constfunc{bool}{IsMainLoopRunning}{\void}
+
+Returns \true if the main event loop is currently running, i.e. if the
+application is inside \helpref{OnRun}{wxapponrun}.
+
+This can be useful to test whether the events can be dispatched. For example,
+if this function returns \false, non-blocking sockets cannot be used because
+the events from them would never be processed.
+
+
 \membersection{wxApp::MainLoop}\label{wxappmainloop}
 
 \func{virtual int}{MainLoop}{\void}
diff --git a/include/wx/app.h b/include/wx/app.h
index d4648e873d..4eae440186 100644
--- a/include/wx/app.h
+++ b/include/wx/app.h
@@ -376,6 +376,17 @@ public:
     // the worker functions - usually not used directly by the user code
     // -----------------------------------------------------------------
 
+        // return true if we're running main loop, i.e. if the events can
+        // (already) be dispatched
+    bool IsMainLoopRunning() const
+    {
+#if wxUSE_EVTLOOP_IN_APP
+        return m_mainLoop != NULL;
+#else
+        return false;
+#endif
+    }
+
         // execute the main GUI loop, the function returns when the loop ends
     virtual int MainLoop();
 
-- 
2.47.2

