Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Task::FromException Method (Exception^)

.NET Framework (current version)
 

Creates a Task that has completed with a specified exception.

Namespace:   System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

public:
static Task^ FromException(
	Exception^ exception
)

Parameters

exception
Type: System::Exception^

The exception with which to complete the task.

Return Value

Type: System.Threading.Tasks::Task^

The faulted task.

This method creates a Task object whose Status property is TaskStatus::Faulted and whose Exception property contains exception. The method is commonly used when you immediately know that the work that a task performs will throw an exception before executing a longer code path. For an example, see the FromException<TResult>(Exception^) overload.

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.6
Return to top
Show:
© 2017 Microsoft