Command.SetAction Method
Definition
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
| 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
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
- action
- Action<ParseResult>
Applies to
SetAction(Func<ParseResult,Int32>)
- 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
- action
- Func<ParseResult,Int32>
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
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
- action
- Func<ParseResult,CancellationToken,Task<Int32>>
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
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
- action
- Func<ParseResult,CancellationToken,Task>
Applies to
SetAction(Func<ParseResult,Task<Int32>>)
- 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
- action
- Func<ParseResult,Task<Int32>>
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
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
- action
- Func<ParseResult,Task>
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.