#if NET20 || NET30 || NET35 || !NET_4_6
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Threading.Tasks
{
///
/// Provides data for the event that is raised when a faulted 's
/// exception goes unobserved.
///
///
/// The Exception property is used to examine the exception without marking it
/// as observed, whereas the method is used to mark the exception
/// as observed. Marking the exception as observed prevents it from triggering exception escalation policy
/// which, by default, terminates the process.
///
public class UnobservedTaskExceptionEventArgs : EventArgs
{
private readonly AggregateException _exception;
private bool _observed;
///
/// Initializes a new instance of the class
/// with the unobserved exception.
///
/// The Exception that has gone unobserved.
public UnobservedTaskExceptionEventArgs(AggregateException exception)
{
_exception = exception;
}
///
/// Marks the as "observed," thus preventing it
/// from triggering exception escalation policy which, by default, terminates the process.
///
public void SetObserved()
{
_observed = true;
}
///
/// Gets whether this exception has been marked as "observed."
///
public bool Observed
{
get { return _observed; }
internal set { _observed = value; }
}
///
/// The Exception that went unobserved.
///
public AggregateException Exception
{
get { return _exception; }
}
}
}
#endif