nn::applet::CTR::WaitForStarting Function

Syntax

AppletWakeupState WaitForStarting(
     AppletId * pSenderId = NULL,
     u8 * pParam = NULL,
     size_t paramSize = 0,
     s32 * pReadLen = NULL,
     nn::Handle * pHandle = NULL,
     nn::fnd::TimeSpan timeout = NN_APPLET_WAIT_INFINITE
);

Arguments

Name Description
out pSenderId ID of the Applet that sent the event.
out pParam Parameter buffer.
in paramSize Parameter buffer size.
out pReadLen Amount of data to read.
out pHandle Handler.
in timeout Timeout interval.

Return Values

Returns the reason that processing was resumed.

Description

Waits for this object's start event.

This function does not return until the start event is received.

This function returns a value from the AppletWakeupState enumerated type. You must use this value to determine what to do next (for example, whether to resume an application normally or close it).

However, because the nn::applet::CTR::IsExpectedToCloseApplication function returns a value of true when the application must be closed, always use nn::applet::CTR::IsExpectedToCloseApplication to make a decision immediately after this function returns instead of simply checking this function's return value directly.

If the application is preparing to close based on the results of this check, then ignore the return value and obtained parameters from this function.

Return ValuesStateExpected Behavior
applet::WAKEUP_SKIPSkipped WaitForStarting.Continues operating.
applet::WAKEUP_TO_STARTWoken up by a normal request.Continues operating.
applet::WAKEUP_BY_EXITWoken up by another applet closing.Continues operating.
applet::WAKEUP_BY_PAUSEWoken up by another applet pausing.Continues operating.
applet::WAKEUP_BY_CANCELWoken up by a cancel notification.Closes.
applet::WAKEUP_BY_POWER_BUTTON_CLICKWoken up by a POWER Button press.Closes.
applet::WAKEUP_BY_TIMEOUTWoken up by timeout.Context-dependent.

The return values obtainable by the application are those listed above.

Example

  applet::WaitForStarting();
  if ( applet::IsExpectedToCloseApplication() )
  {
     _application_finalize(); // Finalizing to release application resources
     applet::PrepareToCloseApplication();
     applet::CloseApplication();
     // Execution doesn't reach this point.
  }

Revision History

2010/12/10
Recommended use of the IsExpectedToCloseApplication function, rather than the return value, to make a decision.
2010/11/30
Added description of checking via IsExpectedToCloseApplication.
2010/11/10
Initial version.

CONFIDENTIAL