Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Command.SetAction Method

Definition

Namespace:
System.CommandLine
Assembly:
System.CommandLine.dll
Package:
System.CommandLine v3.0.0-preview.5.26302.115

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
SetAction(Action<ParseResult>)

Sets a synchronous action to be run when the command is invoked.

SetAction(Func<ParseResult,Int32>)

Sets a synchronous action to be run when the command is invoked.

SetAction(Func<ParseResult,CancellationToken,Task<Int32>>)

Sets an asynchronous action when the command is invoked.

SetAction(Func<ParseResult,CancellationToken,Task>)

Sets an asynchronous action to be run when the command is invoked.

SetAction(Func<ParseResult,Task<Int32>>)

Sets an asynchronous action to be run when the command is invoked.

SetAction(Func<ParseResult,Task>)

Sets an asynchronous action to be run when the command is invoked.

SetAction(Action<ParseResult>)

Source:
Command.cs
Source:
Command.cs

Sets a synchronous action to be run when the command is invoked.

public:
 void SetAction(Action<System::CommandLine::ParseResult ^> ^ action);
public void SetAction(Action<System.CommandLine.ParseResult> action);
member this.SetAction : Action<System.CommandLine.ParseResult> -> unit
Public Sub SetAction (action As Action(Of ParseResult))

Parameters

Applies to

SetAction(Func<ParseResult,Int32>)

Source:
Command.cs
Source:
Command.cs

Sets a synchronous action to be run when the command is invoked.

public:
 void SetAction(Func<System::CommandLine::ParseResult ^, int> ^ action);
public void SetAction(Func<System.CommandLine.ParseResult,int> action);
member this.SetAction : Func<System.CommandLine.ParseResult, int> -> unit
Public Sub SetAction (action As Func(Of ParseResult, Integer))

Parameters

Remarks

The value returned from the action delegate can be used to set the process exit code.

Applies to

SetAction(Func<ParseResult,CancellationToken,Task<Int32>>)

Source:
Command.cs
Source:
Command.cs

Sets an asynchronous action when the command is invoked.

public:
 void SetAction(Func<System::CommandLine::ParseResult ^, System::Threading::CancellationToken, System::Threading::Tasks::Task<int> ^> ^ action);
public void SetAction(Func<System.CommandLine.ParseResult,System.Threading.CancellationToken,System.Threading.Tasks.Task<int>> action);
member this.SetAction : Func<System.CommandLine.ParseResult, System.Threading.CancellationToken, System.Threading.Tasks.Task<int>> -> unit
Public Sub SetAction (action As Func(Of ParseResult, CancellationToken, Task(Of Integer)))

Parameters

Remarks

The value returned from the action delegate can be used to set the process exit code.

Applies to

SetAction(Func<ParseResult,CancellationToken,Task>)

Source:
Command.cs
Source:
Command.cs

Sets an asynchronous action to be run when the command is invoked.

public:
 void SetAction(Func<System::CommandLine::ParseResult ^, System::Threading::CancellationToken, System::Threading::Tasks::Task ^> ^ action);
public void SetAction(Func<System.CommandLine.ParseResult,System.Threading.CancellationToken,System.Threading.Tasks.Task> action);
member this.SetAction : Func<System.CommandLine.ParseResult, System.Threading.CancellationToken, System.Threading.Tasks.Task> -> unit
Public Sub SetAction (action As Func(Of ParseResult, CancellationToken, Task))

Parameters

Applies to

SetAction(Func<ParseResult,Task<Int32>>)

Source:
Command.cs
Source:
Command.cs

Sets an asynchronous action to be run when the command is invoked.

public:
 void SetAction(Func<System::CommandLine::ParseResult ^, System::Threading::Tasks::Task<int> ^> ^ action);
public void SetAction(Func<System.CommandLine.ParseResult,System.Threading.Tasks.Task<int>> action);
member this.SetAction : Func<System.CommandLine.ParseResult, System.Threading.Tasks.Task<int>> -> unit
Public Sub SetAction (action As Func(Of ParseResult, Task(Of Integer)))

Parameters

Remarks

When possible, prefer using the SetAction(Func<ParseResult,CancellationToken,Task<Int32>>) overload and passing the CancellationToken parameter to the async method(s) called by the action.

Applies to

SetAction(Func<ParseResult,Task>)

Source:
Command.cs
Source:
Command.cs

Sets an asynchronous action to be run when the command is invoked.

public:
 void SetAction(Func<System::CommandLine::ParseResult ^, System::Threading::Tasks::Task ^> ^ action);
public void SetAction(Func<System.CommandLine.ParseResult,System.Threading.Tasks.Task> action);
member this.SetAction : Func<System.CommandLine.ParseResult, System.Threading.Tasks.Task> -> unit
Public Sub SetAction (action As Func(Of ParseResult, Task))

Parameters

Remarks

When possible, prefer using the SetAction(Func<ParseResult,CancellationToken,Task>) overload and passing the CancellationToken parameter to the async method(s) called by the action.

Applies to


Feedback

Was this page helpful?