OperationCanceledExceptionExtensions Class
Provides ThrowNew extension methods for OperationCanceledException.
public static class OperationCanceledExceptionExtensionsRemarks
Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in OperationCanceledException.ThrowNew(message).
The first method returns no value. Call it as a statement.
The second method has a type parameter, which is also its return type. Call it where the code needs an expression of that type.
See also
Methods
OperationCanceledException.ThrowNew overloads
OperationCanceledException.ThrowNew()
Throws a new OperationCanceledException.
extension(OperationCanceledException)
{
public static void ThrowNew()
}OperationCanceledException.ThrowNew(string?)
Throws a new OperationCanceledException.
extension(OperationCanceledException)
{
public static void ThrowNew(string? message)
}OperationCanceledException.ThrowNew(string?, Exception?)
Throws a new OperationCanceledException.
extension(OperationCanceledException)
{
public static void ThrowNew(string? message, Exception? innerException)
}Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception.
OperationCanceledException.ThrowNew(string?, Exception?, CancellationToken)
Throws a new OperationCanceledException.
extension(OperationCanceledException)
{
public static void ThrowNew(string? message, Exception? innerException, CancellationToken token)
}Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception. tokenCancellationToken- A cancellation token associated with the operation that was canceled.
OperationCanceledException.ThrowNew(string?, CancellationToken)
Throws a new OperationCanceledException.
extension(OperationCanceledException)
{
public static void ThrowNew(string? message, CancellationToken token)
}Parameters
messagestring?- The error message that explains the reason for the exception.
tokenCancellationToken- A cancellation token associated with the operation that was canceled.
OperationCanceledException.ThrowNew(CancellationToken)
Throws a new OperationCanceledException.
extension(OperationCanceledException)
{
public static void ThrowNew(CancellationToken token)
}Parameters
tokenCancellationToken- A cancellation token associated with the operation that was canceled.
OperationCanceledException.ThrowNew<T>()
Throws a new OperationCanceledException, where the code needs an expression of type T.
extension(OperationCanceledException)
{
public static T ThrowNew<T>()
}Type parameters
T- The type of the expression.
Returns
T This method does not return.
OperationCanceledException.ThrowNew<T>(string?)
Throws a new OperationCanceledException, where the code needs an expression of type T.
extension(OperationCanceledException)
{
public static T ThrowNew<T>(string? message)
}OperationCanceledException.ThrowNew<T>(string?, Exception?)
Throws a new OperationCanceledException, where the code needs an expression of type T.
extension(OperationCanceledException)
{
public static T ThrowNew<T>(string? message, Exception? innerException)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception.
Returns
T This method does not return.
OperationCanceledException.ThrowNew<T>(string?, Exception?, CancellationToken)
Throws a new OperationCanceledException, where the code needs an expression of type T.
extension(OperationCanceledException)
{
public static T ThrowNew<T>(string? message, Exception? innerException, CancellationToken token)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception. tokenCancellationToken- A cancellation token associated with the operation that was canceled.
Returns
T This method does not return.
OperationCanceledException.ThrowNew<T>(string?, CancellationToken)
Throws a new OperationCanceledException, where the code needs an expression of type T.
extension(OperationCanceledException)
{
public static T ThrowNew<T>(string? message, CancellationToken token)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
tokenCancellationToken- A cancellation token associated with the operation that was canceled.
Returns
T This method does not return.
OperationCanceledException.ThrowNew<T>(CancellationToken)
Throws a new OperationCanceledException, where the code needs an expression of type T.
extension(OperationCanceledException)
{
public static T ThrowNew<T>(CancellationToken token)
}Type parameters
T- The type of the expression.
Parameters
tokenCancellationToken- A cancellation token associated with the operation that was canceled.
Returns
T This method does not return.