{"id":1516,"date":"2022-08-30T15:17:11","date_gmt":"2022-08-30T15:17:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/26\/monodroid-looper-myqueue-hangs-on-some-activities-idle-handler-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:11","modified_gmt":"2022-08-30T15:17:11","slug":"monodroid-looper-myqueue-hangs-on-some-activities-idle-handler-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/monodroid-looper-myqueue-hangs-on-some-activities-idle-handler-collection-of-common-programming-errors\/","title":{"rendered":"MonoDroid Looper.MyQueue() hangs on some activities \/ Idle Handler?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m using MonoDroid <code>Looper.MyQueue().AddIdleHandler()<\/code> to execute some Commands when the app is in idle mode. This is working in one activity, but if I&#8217;m starting the second activity it hangs until i touch the screen or restart the first activity. Theres no loop or anything which could block the queue in the second activity. How can i prevent the looper from hanging?<\/p>\n<pre><code>Looper.MyQueue().AddIdleHandler(new ExecuteRunner(appState));\npublic class ExecuteRunner : Java.Lang.Object, MessageQueue.IIdleHandler\n{\n    int count = 0;\n    ApplicationState appState;\n    public ExecuteRunner(ApplicationState pAppState)\n    {\n        appState = pAppState;\n    }\n\n    public bool QueueIdle()\n    {\n        appState.YooManager.Manager.ExecuteCommand();\n        count++;\n        Android.Util.Log.Debug(\"YooBik-Exe\", count.ToString());\n        return true;\n    }\n}\n<\/code><\/pre>\n<p>Could the message queue be blocked by something? In the activity where the idle handler isn&#8217;t working the OnTouch event is registered.<\/p>\n<p>Or does anybody know another way how to implement an idle handler for monodroid?<\/p>\n<ol>\n<li>\n<p>If it hangs until you touch screen I guess it waits on MessageQueue.next() ( line this.wait(); ). Because your main activity looper.loop() calls MessageQueue.next() and what it does : while(ture) { 1. pullNextLocked() and returns if there is some msg to execute. otherwise : 2. execute all queueIdle()&#8217;s. and then 3. this.wait();<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-26 18:03:05. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using MonoDroid Looper.MyQueue().AddIdleHandler() to execute some Commands when the app is in idle mode. This is working in one activity, but if I&#8217;m starting the second activity it hangs until i touch the screen or restart the first activity. Theres no loop or anything which could block the queue in the second activity. How [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1516","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1516"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1516\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}