NLog.Targets.Target.WriteAsyncLogEvents C# (CSharp) Method

WriteAsyncLogEvents() public method

Writes the array of log events.
public WriteAsyncLogEvents ( ) : void
return void
        public void WriteAsyncLogEvents(params AsyncLogEventInfo[] logEvents)
        {
            lock (this.SyncRoot)
            {
                if (!this.IsInitialized)
                {
                    foreach (var ev in logEvents)
                    {
                        ev.Continuation(null);
                    }

                    return;
                }

                if (this.initializeException != null)
                {
                    foreach (var ev in logEvents)
                    {
                        ev.Continuation(this.CreateInitException());
                    }

                    return;
                }

                var wrappedEvents = new AsyncLogEventInfo[logEvents.Length];
                for (int i = 0; i < logEvents.Length; ++i)
                {
                    wrappedEvents[i] = logEvents[i].LogEvent.WithContinuation(AsyncHelpers.PreventMultipleCalls(logEvents[i].Continuation));
                }

                try
                {
                    this.Write(wrappedEvents);
                }
                catch (Exception exception)
                {
                    if (exception.MustBeRethrown())
                    {
                        throw;
                    }

                    // in case of synchronous failure, assume that nothing is running asynchronously
                    foreach (var ev in wrappedEvents)
                    {
                        ev.Continuation(exception);
                    }
                }
            }
        }

Same methods

Target::WriteAsyncLogEvents ( NLog.Common.AsyncLogEventInfo logEventInfos, AsyncContinuation continuation ) : void