<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Doing stuff while drawing is halted</title>
		<link>http://www.allegro.cc/forums/view/615114</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 25 Feb 2015 05:27:48 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I notice that when drawing is halted, e.g., an app is in the background, Allegro blocks until you return. The problem with that for me is that  RakNet is paranoid and if it does not hear from me in a timely manner, it will drop my connection.</p><p>Therefore, if a user goes to the background for about 5 seconds, they get kicked from the server which is not desired.</p><p>Is there some way I can continue to call my net-&gt;tick(); function while my App is in the background? I can always start a thread to do it, but I would prefer not to involve multithreading if possible.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Mon, 23 Feb 2015 09:42:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you know where it is blocking? <span class="source-code"><a href="http://www.allegro.cc/manual/al_wait_for_event"><span class="a">al_wait_for_event</span></a></span> perhaps? I know you get an event when you switch out, and drawing is halted.. if you notice that, you can probably just skip the <span class="source-code"><a href="http://www.allegro.cc/manual/al_wait_for_event"><span class="a">al_wait_for_event</span></a></span> and just start polling raknet occasionally?</p><p>Or instead of a plain <span class="source-code"><a href="http://www.allegro.cc/manual/al_wait_for_event"><span class="a">al_wait_for_event</span></a></span> you use <span class="source-code"><a href="http://www.allegro.cc/manual/al_wait_for_event_timed"><span class="a">al_wait_for_event_timed</span></a></span> to let it timeout and then process raknet.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 23 Feb 2015 09:59:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks! al_wait_for_event_timed was just what I was looking for! The reason I need it is I need to receive the event when things resume.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Mon, 23 Feb 2015 11:44:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You should always get a resume event when things resume.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 23 Feb 2015 12:50:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>From what I can see from testing, a few seconds after calling al_acknowledge_drawing_halt Allegro just pauses all execution on all my threads, I even tried creating a thread that jus prints hello and even that stopped printing a few seconds later and started printing again when I returned. It is not iOS doing this, I made a test and eliminating Allegro lets me do stuff when I&#39;m in the background.</p><p>So right now I have to way to keep the network thread alive <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" /></p><p>If I omit acknowledging the halt, my networking keeps running fine, but then I can never get the resume because I never called the acknowledge_halt...</p><p>Odd thing though is I don&#39;t see anything in Allegro&#39;s source that indicates it locks threads on drawing halt.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Tue, 24 Feb 2015 11:11:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ALLEGRO_EVENT_DISPLAY_HALT_DRAWING is done whenever ios sends this to the application: <span class="ref"><sup>[<a href="#">1</a>]</sup></span></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If the method does not return before time runs out your app is terminated and purged from memory. 
</p></div></div><p>

So no, just continuing is not an option, according to Apple. You probably have to register your app as a special background application (those displaying a little icon at the top) to keep any network activity while it is switched out. I don&#39;t know details how to do it, but a normal application definitely cannot keep running in the back under iOS.
</p><div class="ref-block"><h2>References</h2><ol><li><a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIApplicationDelegate/applicationDidEnterBackground">https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIApplicationDelegate/applicationDidEnterBackground</a></li></ol></div></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Tue, 24 Feb 2015 19:35:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the info. I was not aware of how all that worked.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Tue, 24 Feb 2015 20:46:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, I wasn&#39;t thinking this was on mobile. Yeah, you basically need to take that into account...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 25 Feb 2015 05:27:48 +0000</pubDate>
	</item>
</rss>
