共用方式為


PSHost.SetShouldExit(Int32) Method

Definition

Request by the engine to end the current engine runspace (to shut down and terminate the host's root runspace).

public:
 abstract void SetShouldExit(int exitCode);
public:
 abstract void SetShouldExit(int exitCode);
 abstract void SetShouldExit(int exitCode);
public abstract void SetShouldExit (int exitCode);
abstract member SetShouldExit : int -> unit
Public MustOverride Sub SetShouldExit (exitCode As Integer)

Parameters

exitCode
Int32

The exit code accompanying the exit keyword. Typically, after exiting a runspace, a host will also terminate. The exitCode parameter can be used to set the host's process exit code.

Remarks

This method is called by the engine to request the host shutdown the engine. This is invoked by the exit keyword or by any other facility by which a runspace instance wishes to be shut down.

To honor this request, the host should stop accepting and submitting commands to the engine and close the runspace.

Applies to