public void IterationSetup()
 {
     _backgroundWorker = new BackgroundWorker(new FakeTransport(), new SentryOptions {
         MaxQueueItems = 1000
     });
     _event = new SentryEvent();
     // Make sure worker spins once.
     _backgroundWorker.EnqueueEvent(_event);
     _backgroundWorker.FlushAsync(TimeSpan.FromSeconds(10)).GetAwaiter().GetResult();
     for (var i = 0; i < Items; i++)
     {
         _backgroundWorker.EnqueueEvent(_event);
     }
 }
示例#2
0
        public Guid CaptureEvent(SentryEvent @event, Scope scope = null)
        {
            var id = _failureId;

            scope?.Evaluate();

            scope?.CopyTo(@event);

            if (_options.BeforeSend != null)
            {
                @event = _options.BeforeSend?.Invoke(@event);
                if (@event == null) // Rejected event
                {
                    return(id);
                }
            }

            if (_worker.EnqueueEvent(@event))
            {
                id = @event.EventId;
            }
            else
            {
                // TODO: Notify error handler
                Debug.WriteLine("Failed to enqueue event. Current queue depth: " + _worker.QueuedItems);
            }

            return(id);
        }