本文整理汇总了C#中System.Runtime.ExceptionServices.ExceptionDispatchInfo类的典型用法代码示例。如果您正苦于以下问题:C# ExceptionDispatchInfo类的具体用法?C# ExceptionDispatchInfo怎么用?C# ExceptionDispatchInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionDispatchInfo类属于System.Runtime.ExceptionServices命名空间,在下文中一共展示了ExceptionDispatchInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnTimeoutExceptionAsync
public async Task OnTimeoutExceptionAsync(ExceptionDispatchInfo exceptionInfo, TimeSpan timeoutGracePeriod)
{
FunctionTimeoutException timeoutException = exceptionInfo.SourceException as FunctionTimeoutException;
if (timeoutException?.Task != null)
{
// We may double the timeoutGracePeriod here by first waiting to see if the iniital
// function task that started the exception has completed.
Task completedTask = await Task.WhenAny(timeoutException.Task, Task.Delay(timeoutGracePeriod));
// If the function task has completed, simply return. The host has already logged the timeout.
if (completedTask == timeoutException.Task)
{
return;
}
}
LogErrorAndFlush("A function timeout has occurred. Host is shutting down.", exceptionInfo.SourceException);
// We can't wait on this as it may cause a deadlock if the timeout was fired
// by a Listener that cannot stop until it has completed.
Task ignoreTask = _manager.StopAsync();
// Give the manager and all running tasks some time to shut down gracefully.
await Task.Delay(timeoutGracePeriod);
HostingEnvironment.InitiateShutdown();
}
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:28,代码来源:WebScriptHostExceptionHandler.cs
示例2: ExceptionContext
/// <summary>
/// Initializes a new instance of the <see cref="ExceptionContext"/> class using the values provided.
/// </summary>
/// <param name="exceptionInfo">The exception caught.</param>
/// <param name="catchBlock">The catch block where the exception was caught.</param>
/// <param name="context">The context in which the exception occurred.</param>
public ExceptionContext(ExceptionDispatchInfo exceptionInfo, ExceptionContextCatchBlock catchBlock, CommandHandlerContext context)
{
if (exceptionInfo == null)
{
throw new ArgumentNullException("exceptionInfo");
}
this.ExceptionInfo = exceptionInfo;
if (catchBlock == null)
{
throw new ArgumentNullException("catchBlock");
}
this.CatchBlock = catchBlock;
if (context == null)
{
throw new ArgumentNullException("context");
}
this.Context = context;
CommandHandlerRequest request = context.Request;
if (request == null)
{
throw Error.ArgumentNull(Resources.TypePropertyMustNotBeNull, typeof(HandlerRequest).Name, "Request", "context");
}
this.Request = request;
}
开发者ID:ctguxp,项目名称:Waffle,代码行数:38,代码来源:ExceptionContext.cs
示例3: SignalFailure
internal void SignalFailure(ExceptionDispatchInfo error)
{
if (_storedException == null)
{
_storedException = error;
}
SignalComplete();
}
开发者ID:dmetzgar,项目名称:corefx,代码行数:8,代码来源:CurlResponseMessage.cs
示例4: EventHandlerOccurredContext
/// <summary>
/// Initializes a new instance of the <see cref="EventHandlerOccurredContext"/> class.
/// </summary>
/// <param name="handlerContext">Then handler context.</param>
/// <param name="exceptionInfo">The <see cref="ExceptionDispatchInfo"/>. Optionnal.</param>
public EventHandlerOccurredContext(EventHandlerContext handlerContext, ExceptionDispatchInfo exceptionInfo)
{
if (handlerContext == null)
{
throw Error.ArgumentNull("handlerContext");
}
this.handlerContext = handlerContext;
this.ExceptionInfo = exceptionInfo;
}
开发者ID:ctguxp,项目名称:Waffle,代码行数:15,代码来源:EventHandlerOccuredContext.cs
示例5: CommandHandlerExecutedContext
/// <summary>
/// Initializes a new instance of the <see cref="CommandHandlerExecutedContext"/> class.
/// </summary>
/// <param name="handlerContext">Then handler context.</param>
/// <param name="exceptionInfo">The <see cref="ExceptionDispatchInfo"/>. Optionnal.</param>
public CommandHandlerExecutedContext(CommandHandlerContext handlerContext, ExceptionDispatchInfo exceptionInfo)
{
if (handlerContext == null)
{
throw Error.ArgumentNull("handlerContext");
}
this.ExceptionInfo = exceptionInfo;
this.handlerContext = handlerContext;
}
开发者ID:ctguxp,项目名称:Waffle,代码行数:15,代码来源:CommandHandlerExecutedContext.cs
示例6: HttpRouteExceptionHandler
internal HttpRouteExceptionHandler(ExceptionDispatchInfo exceptionInfo,
IExceptionLogger exceptionLogger, IExceptionHandler exceptionHandler)
{
Contract.Assert(exceptionInfo != null);
Contract.Assert(exceptionLogger != null);
Contract.Assert(exceptionHandler != null);
_exceptionInfo = exceptionInfo;
_exceptionLogger = exceptionLogger;
_exceptionHandler = exceptionHandler;
}
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:11,代码来源:HttpRouteExceptionHandler.cs
示例7: Throw
public void Throw(ExceptionDispatchInfo exceptionInfo)
{
Debug.Assert(exceptionInfo != null);
Thread thread = new Thread(() =>
{
exceptionInfo.Throw();
});
thread.Start();
thread.Join();
}
开发者ID:rafaelmtz,项目名称:azure-webjobs-sdk,代码行数:11,代码来源:BackgroundExceptionDispatcher.cs
示例8: SetException
public void SetException (AggregateException exception)
{
#if NET_4_5
if (dispatchInfo == null) {
//
// Used by task awaiter to rethrow an exception with original call stack, it's
// needed for first exception only
//
dispatchInfo = ExceptionDispatchInfo.Capture (exception.InnerException);
}
#endif
this.exception = exception;
}
开发者ID:genoher,项目名称:mono,代码行数:13,代码来源:TaskExceptionSlot.cs
示例9: AllocException
private IntPtr AllocException(Exception ex)
{
_lastException = ExceptionDispatchInfo.Capture(ex);
string exString = ex.ToString();
IntPtr nativeException = AllocException(exString, exString.Length);
if (_nativeExceptions == null)
{
_nativeExceptions = new List<IntPtr>();
}
_nativeExceptions.Add(nativeException);
return nativeException;
}
开发者ID:stephentoub,项目名称:corert,代码行数:13,代码来源:CorInfoImpl.cs
示例10: CallCallbackPossiblyUnderLock
private void CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) {
ThreadContext threadContext = null;
try {
threadContext = _application.OnThreadEnter();
try {
callback(state);
}
catch (Exception e) {
_error = ExceptionDispatchInfo.Capture(e);
}
}
finally {
if (threadContext != null) {
threadContext.DisassociateFromCurrentThread();
}
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:17,代码来源:LegacyAspNetSynchronizationContext.cs
示例11: ThrowEntryPoint
private static void ThrowEntryPoint()
{
if (s_EDI == null)
{
try
{
ThrowEntryPointInner();
}
catch(Exception ex)
{
Console.WriteLine("Caught exception with message: {0}", ex.Message);
s_EDI = ExceptionDispatchInfo.Capture(ex);
}
}
else
{
Console.WriteLine("s_Exception is not null!");
s_EDI = null;
}
}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:20,代码来源:StackTracePreserveTests.cs
示例12: CheckRetryForExceptionAsync
private async Task CheckRetryForExceptionAsync(ExceptionDispatchInfo ex, bool reinitialize)
{
if (simulator.AsyncRetryHandler == null)
{
// Simply rethrow the exception.
ex.Throw();
}
else
{
// Need to release active keys etc.
CancelActiveInteractions();
bool result = await simulator.AsyncRetryHandler(ex);
if (!result)
throw new SimulatorCanceledException();
// When trying again, we need to re-initialize.
if (reinitialize)
await InitializeAsync();
}
}
开发者ID:kpreisser,项目名称:MouseClickSimulator,代码行数:21,代码来源:StandardInteractionProvider.cs
示例13: Run
/// <summary>
/// Enqueues the function to be executed and executes all resulting continuations until it is completely done
/// </summary>
public void Run()
{
Post(async _ =>
{
try
{
await _task();
}
catch (Exception exception)
{
_caughtException = ExceptionDispatchInfo.Capture(exception);
throw;
}
finally
{
Post(state => _done = true, null);
}
}, null);
while (!_done)
{
Tuple<SendOrPostCallback, object> task;
if (_items.TryDequeue(out task))
{
task.Item1(task.Item2);
if (_caughtException == null) continue;
_caughtException.Throw();
}
else
{
_workItemsWaiting.WaitOne();
}
}
}
开发者ID:rebus-org,项目名称:Rebus,代码行数:40,代码来源:AsyncHelpers.cs
示例14: SetCancellationException
/// <summary>Sets the cancellation exception.</summary>
/// <param name="exceptionObject">The cancellation exception.</param>
/// <remarks>
/// Must be called under lock.
/// </remarks>
private void SetCancellationException(object exceptionObject)
{
Contract.Requires(exceptionObject != null, "Expected exceptionObject to be non-null.");
Debug.Assert(m_cancellationException == null,
"Expected SetCancellationException to be called only once.");
// Breaking this assumption will overwrite a previously OCE,
// and implies something may be wrong elsewhere, since there should only ever be one.
Debug.Assert(m_faultExceptions == null,
"Expected SetCancellationException to be called before any faults were added.");
// Breaking this assumption shouldn't hurt anything here, but it implies something may be wrong elsewhere.
// If this changes, make sure to only conditionally mark as handled below.
// Store the cancellation exception
var oce = exceptionObject as OperationCanceledException;
if (oce != null)
{
m_cancellationException = ExceptionDispatchInfo.Capture(oce);
}
else
{
var edi = exceptionObject as ExceptionDispatchInfo;
Debug.Assert(edi != null && edi.SourceException is OperationCanceledException,
"Expected an OCE or an EDI that contained an OCE");
m_cancellationException = edi;
}
// This is just cancellation, and there are no faults, so mark the holder as handled.
MarkAsHandled(false);
}
开发者ID:adityamandaleeka,项目名称:corert,代码行数:36,代码来源:TaskExceptionHolder.cs
示例15: StartSendAuthResetSignal
//
// This is to reset auth state on remote side.
// If this write succeeds we will allow auth retrying.
//
private void StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
{
if (message == null || message.Size == 0)
{
//
// We don't have an alert to send so cannot retry and fail prematurely.
//
exception.Throw();
}
if (asyncRequest == null)
{
InnerStream.Write(message.Payload, 0, message.Size);
}
else
{
asyncRequest.AsyncState = exception;
IAsyncResult ar = InnerStreamAPM.BeginWrite(message.Payload, 0, message.Size, s_writeCallback, asyncRequest);
if (!ar.CompletedSynchronously)
{
return;
}
InnerStreamAPM.EndWrite(ar);
}
exception.Throw();
}
开发者ID:eerhardt,项目名称:corefx,代码行数:31,代码来源:SslState.cs
示例16: Close
//
// This is to not depend on GC&SafeHandle class if the context is not needed anymore.
//
internal void Close()
{
_exception = ExceptionDispatchInfo.Capture(new ObjectDisposedException("SslStream"));
if (Context != null)
{
Context.Close();
}
}
开发者ID:eerhardt,项目名称:corefx,代码行数:11,代码来源:SslState.cs
示例17: CreateProductUnderTest
private static HttpRouteExceptionHandler CreateProductUnderTest(ExceptionDispatchInfo exceptionInfo)
{
return new HttpRouteExceptionHandler(exceptionInfo);
}
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:4,代码来源:HttpRouteExceptionHandlerTests.cs
示例18: RegisterAsyncCompletion
// Invoked from the callback to signal that the End* method has run to completion.
// Returns 'true' if the current thread should call ResumeSteps, 'false' if not.
public bool RegisterAsyncCompletion(Exception error) {
// Before the call to Exchange below, the _asyncCompletionInfo field will have the value
// ASYNC_STATE_NONE or ASYNC_STATE_BEGIN_UNWOUND. If it's the former, then the Begin* method
// hasn't yet returned control to IExecutionStep.Execute. From this step's point of view,
// this can be treated as a synchronous completion, which will allow us to call ResumeSteps
// on the original thread and save the cost of destroying the existing ThreadContext and
// creating a new one. If the original value is instead ASYNC_STATE_BEGIN_UNWOUND, then
// the Begin* method already returned control to IExecutionStep.Execute and this step was
// marked as having an asynchronous completion. The original thread will tear down the
// ThreadContext, so the current thread should call back into ResumeSteps to resurrect it.
//
// If there was an error, we'll use the _error field to store it so that IExecutionStep.Execute
// can rethrow it as it's unwinding.
// Interlocked performs a volatile write; all processors will see the write to _error as being
// no later than the write to _asyncState.
_error = (error != null) ? ExceptionDispatchInfo.Capture(error) : null;
int originalState = Interlocked.Exchange(ref _asyncState, ASYNC_STATE_CALLBACK_COMPLETED);
if (originalState == ASYNC_STATE_NONE) {
return false; // IExecutionStep.Execute should call ResumeSteps
}
Debug.Assert(originalState == ASYNC_STATE_BEGIN_UNWOUND, "Unexpected state.");
_error = null; // to prevent long-lived exception object; write doesn't need to be volatile since nobody reads this field anyway in this case
return true; // this thread should call ResumeSteps
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:28,代码来源:HttpApplication.cs
示例19: SetCustomLoaderFailure
private static void SetCustomLoaderFailure(string appId, ExceptionDispatchInfo error) {
_customLoaderStartupError = new KeyValuePair<string, ExceptionDispatchInfo>(appId, error);
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:3,代码来源:ProcessHost.cs
示例20: ReportError
public void ReportError() {
// Using ExceptionDispatchInfo preserves the Exception's stack trace when rethrowing.
ExceptionDispatchInfo error = _error;
if (error != null) {
_error = null; // prevent long-lived Exception objects on the heap
error.Throw();
}
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:8,代码来源:HttpApplication.cs
注:本文中的System.Runtime.ExceptionServices.ExceptionDispatchInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论