public ValueTask OnEngineCompleteAsync(ConsoleAppContext context, string?errorMessageIfFailed, Exception?exceptionIfExists) { this.CompleteSuccessfully = (errorMessageIfFailed == null && exceptionIfExists == null); this.ErrorMessage = errorMessageIfFailed; this.Exception = exceptionIfExists; return(innerInterceptor.OnEngineCompleteAsync(context, errorMessageIfFailed, exceptionIfExists)); }
public override async ValueTask Invoke(ConsoleAppContext context, Func <ConsoleAppContext, ValueTask> next) { try { await next(context); this.CompleteSuccessfully = true; } catch (Exception ex) { this.CompleteSuccessfully = false; this.Exception = ex; } }
public override async ValueTask Invoke(ConsoleAppContext context, Func <ConsoleAppContext, ValueTask> next) { context.Logger.LogInformation("Call method at " + context.Timestamp.ToLocalTime()); // LocalTime for human readable time try { await next(context); context.Logger.LogInformation("Call method Completed successfully, Elapsed:" + (DateTimeOffset.UtcNow - context.Timestamp)); } catch { context.Logger.LogInformation("Call method Completed Failed, Elapsed:" + (DateTimeOffset.UtcNow - context.Timestamp)); throw; } }
public override async ValueTask Invoke(ConsoleAppContext context, Func <ConsoleAppContext, ValueTask> next) { using (var mutex = new Mutex(false, context.MethodInfo.Name)) { if (!mutex.WaitOne(0, false)) { throw new Exception($"already running {context.MethodInfo.Name} in another process."); } try { await next(context); } finally { mutex.ReleaseMutex(); } } }
public ValueTask OnMethodBeginAsync(ConsoleAppContext context) { return(innerInterceptor.OnMethodBeginAsync(context)); }
public async override ValueTask Invoke(ConsoleAppContext context, Func <ConsoleAppContext, ValueTask> next) { Console.WriteLine("call second"); await next(context); }