共用方式為


execAtPriority method

[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]

Runs the specified callback function at the given contextual priority.

Internet Explorer 10

 

Syntax

var retval = MSApp.execAtPriority(synchronousCallback, priority, args);

Parameters

  • synchronousCallback [in]
    Type: function

    The callback function to run synchronously at the given priority contextual priority.

  • priority [in]
    Type: DOMString

    The specified priority value to which the current contextual priority value will be set when running the synchronousCallback callback function. See MSApp Constants.

  • args [in]
    Type: any

    An optional series of arguments that are passed to the synchronousCallback callback function (as parameters 1 and on).

Return value

Type: Any

Returns the return value of the synchronousCallback callback (as applicable).

Remarks

The provided synchronousCallback callback method is execute synchronously. The current contextual priority is changed to the provided priority value (given by the priority argument) for the duration of the provided callback function. Once the callback function finishes executing, priority is returned to the previous value prior to the execAtPriority call. The return value from execAtPriority is the return value of the callback method (as provided).

The synchronousCallback callback parameter can be any function. If any arguments are provided after the priority parameter, they will be passed to the provided callback method. If the callback parameter returns a value, this value becomes the return value for execAtPriority as well.

Examples

var user = Windows.System.UserProfile.UserInformation;

MSApp.execAtPriority(function () { // This callback executes synchronously.
  user.getFirstNameAsync().then(function () { // Dispatches at high priority.
    return user.getLastNameAsync();
  }).done(function () { // Dispatches at high priority.
    // USEFUL CODE HERE
  });
}, MSApp.HIGH); // The second argument of the execAtPriority method.

See also

MSApp

execAsyncAtPriority

MSApp Constants