1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" /> 7<title>IsExpectedToCloseApplication</title> 8 </head> 9 <body> 10<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/applet/Overview.html">applet</a>::<a href="../../../nn/applet/CTR/Overview.html">CTR</a>::IsExpectedToCloseApplication</CODE> Function</h1> 11<h2>Syntax</h2> 12 <div class="section"> 13 <pre class="definition"> 14bool IsExpectedToCloseApplication( 15 void 16); 17</pre> 18 </div> 19<h2>Arguments</h2> 20 <div class="section"> 21<p>None.</p> 22 </div> 23<h2>Return Values</h2> 24<div class="section"><CODE>true</CODE> indicates that the application should be closed and <CODE>false</CODE> indicates that the application does not need to be closed. </div> 25<h2>Description</h2> 26 <div class="section"> 27<p>Determines whether an application should be closed.</p><!-- write here --><P> 28A return value of <CODE>true</CODE> indicates that the shutdown process has started because there was a close request or for some other reason. In this case, close the application immediately. 29</P><P> 30A return value of <CODE>false</CODE> indicates that the application does not need to be closed. In this case, do nothing. 31<P /> 32Call this function periodically (usually every frame). <FONT color="red">You must also check immediately after returning from a function that is waiting on <CODE>WaitForStarting</CODE>. </FONT> Again, also check after execution of the <a href="../../../nn/applet/CTR/Enable.html"><CODE>nn::applet::CTR::Enable</CODE></a> function. 33</P><P> 34Do this before calling any of the other check functions in the APPLET library (<a href="../../../nn/applet/CTR/IsExpectedToProcessHomeButton.html"><CODE>nn::applet::CTR::IsExpectedToProcessHomeButton</CODE></a>, <a href="../../../nn/applet/CTR/IsExpectedToProcessPowerButton.html"><CODE>nn::applet::CTR::IsExpectedToProcessPowerButton</CODE></a>, and <a href="../../../nn/applet/CTR/IsExpectedToReplySleepQuery.html"><CODE>nn::applet::CTR::IsExpectedToReplySleepQuery</CODE></a>) once control has returned from the waiting state. 35</P><P> 36Example 37</P><PRE> 38nnMain() 39{ 40 ... 41 while(1) 42 { 43 _exec(); 44 _draw(); 45 46 // Checking for close after each frame 47 if ( <FONT color="red">applet::IsExpectedToCloseApplication()</FONT> ) 48 { 49 _application_finalize(); 50 applet::PrepareToCloseApplication(); 51 applet::CloseApplication(); 52 // Execution does not reach this point 53 } 54 55 // Launch library applet after pressing the A Button 56 if ( _pushed_A_button() ) 57 { 58 _start_library_applet(); 59 60 // Wait for return from library applet 61 applet::WaitForStarting(); 62 63 // Check for close after control returns from awaiting 64 if ( <FONT color="red">applet::IsExpectedToCloseApplication()</FONT> ) 65 { 66 _application_finalize(); 67 applet::PrepareToCloseApplication(); 68 applet::CloseApplication(); 69 // Execution does not reach this point 70 } 71 } 72 ... 73</PRE><P>If the card is removed, the system displays that fact on the screen, but the application still has not terminated at this point.<BR>If the HOME Button is pressed on the screen indicating card removal detected, control returns to the application and an exit notification is then sent to the application. This exit notification is handled by this function in the usual manner. 74</P><P>However, because there may be times at which this function cannot be called due to the application status when the card was removed, the system is designed to close the application forcibly after a set period of time even if the application does not exit on its own. 75</P><P>In addition, when control returns to the application from the card removal screen, both the upper and lower screens go black (LCD off status). This results in a state where rendering by the GPU is impossible and execution is blocked if the <CODE>nngxWaitCmdlistDone</CODE> function is blocked. In other words, depending on the exact timing the card was removed and how the application is implemented, execution may be blocked by the <CODE>nngxWaitCmdlistDone</CODE> function before exit notification arrives, meaning control may never reach termination by this function. 76</P><P> 77It was originally assumed that determination functions, such as this one, and actual transition operation functions would be called in sequence from the same thread, but it is possible to have a mechanism where they are respectively called from separate threads. In such cases, however, sufficient care is needed such that there is nothing following the transition target operation during the working of the determination thread. 78</P></div> 79<h2>Revision History</h2> 80 <div class="section"> 81 <dl class="history"> 82 <dt>2012/11/09</dt> 83<dd>Added information on calling determination functions and transition functions from separate threads. 84<br /> </dd> 85 <dt>2011/07/06</dt> 86<dd>Added information about behaviors when a card is removed.<BR> 87 </dd> 88 <dt>2010/12/31</dt> 89<dd>Noted that this must also be called after the <CODE>Enable</CODE> function.<br /> 90 </dd> 91 <dt>2010/12/10</dt> 92<dd>Removed a clause about closing an application because of the POWER Button. 93 </dd> 94 <dt>2010/11/30</dt> 95<dd>Initial version.<br /> 96 </dd> 97 </dl> 98 </div> 99 <hr><p>CONFIDENTIAL</p></body> 100</html>