Sdílet prostřednictvím


PSHost.NotifyBeginApplication Method

Definition

Called by the engine to notify the host that it is about to execute a "legacy" command line application. A legacy application is defined as a console-mode executable that may do one or more of the following: . reads from stdin . writes to stdout . writes to stderr . uses any of the win32 console APIs.

public:
 abstract void NotifyBeginApplication();
public:
 abstract void NotifyBeginApplication();
 abstract void NotifyBeginApplication();
public abstract void NotifyBeginApplication ();
abstract member NotifyBeginApplication : unit -> unit
Public MustOverride Sub NotifyBeginApplication ()

Remarks

Notifying the host allows the host to do such things as save off any state that might need to be restored when the legacy application terminates, set or remove break handler hooks, redirect stream handles, and so forth.

The engine will always call this method and the NotifyEndApplication method in matching pairs.

The engine may call this method several times in the course of a single pipeline. For instance, the pipeline:

foo.exe | bar-cmdlet | baz.exe

Will result in a sequence of calls similar to the following: NotifyBeginApplication - called once when foo.exe is started NotifyBeginApplication - called once when baz.exe is started NotifyEndApplication - called once when baz.exe terminates NotifyEndApplication - called once when foo.exe terminates

Note that the order in which the NotifyEndApplication call follows the corresponding call to NotifyBeginApplication with respect to any other call to NotifyBeginApplication is not defined, and should not be depended upon. In other words, NotifyBeginApplication may be called several times before NotifyEndApplication is called. The only thing that is guaranteed is that there will be an equal number of calls to NotifyEndApplication as to NotifyBeginApplication.

Applies to

See also