System.Collections.Concurrent.ConcurrentBag.Add(System.Exception)

Here are the examples of the csharp api class System.Collections.Concurrent.ConcurrentBag.Add(System.Exception) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

15 Examples 7

1. Example

Project: corewf
Source File: ForEach.cs
[Fact]
        public void ForEachWithSynchCollection()
        {
            //  Test case descript/n ..... /n //View Source file for more details /n }

2. Example

Project: ET4W
Source File: MemoryRetentionSink.cs
public void OnError(Exception error)
        {
            RetainedErrors.Add(error);
        }

3. Example

Project: Akavache
Source File: Stresser.cs
void RunAction(string key, Action<string> action)
        {
            try
            {
                while (isRunning)
                {
                    try
                    {
                        action(key);
                    }
                    catch (KeyNotFoundException)
                    {
                        // continue. This is to be expected.
                    }
                }
            }
            catch (Exception e)
            {
                isRunning = false;
                exceptions.Add(e);
            }
        }

4. Example

Project: log4net.ElasticSearch
Source File: ErrorHandlerStub.cs
public void Error(string message, Exception e)
        {
            exceptions.Add(e);
            messages.Add(message);
        }

5. Example

Project: ET4W
Source File: MemoryRetentionSink.cs
public void OnNext(EventEntry value)
        {
            if (value == null)
            {
                RetainedErrors.Add(new InvalidOperationException("null value received in OnNext"));
                return;
            }

            RetainedEvents.Add(
                new EventRecord(value.EventId, value.FormattedMessage, new ReadOnlyCollection<object>(value.Payload.ToArray()), value.Timestamp));
        }

6. Example

Project: EventFlow
Source File: RabbitMqTests.cs
private static async Task SendMessagesAsync(
            IRabbitMqPublisher rabbitMqPublisher,
            int count,
            Exchange exchange,
            RoutingKey routingKey,
            ConcurrentBag<Exception> exceptions)
        {
            var guid = Guid.NewGuid();

            try
            {
                for (var i = 0; i < count; i++)
                {
                    var rabbitMqMessage = new RabbitMqMessage(
                        $"{guid}-{i}",
                        new Metadata(),
                        exchange,
                        routingKey,
                        new MessageId(Guid.NewGuid().ToString("D")));
                    await rabbitMqPublisher.PublishAsync(CancellationToken.None, rabbitMqMessage).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                exceptions.Add(e);
            }
        }

7. Example

Project: Pomona
Source File: TypeMapperTests.cs
[Test]
        public void Resolve_types_from_a_lot_of_threads_does_not_cause_exceptions_due_to_race/n ..... /n //View Source file for more details /n }

8. Example

Project: nhibernate-core
Source File: LogsFixture.cs
[Test]
		public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
		{
			GlobalContext.Pro/n ..... /n //View Source file for more details /n }

9. Example

Project: nhibernate-core
Source File: LogsFixture.cs
[Test]
		public void WillGetSessionIdFromSessionLogsConcurrent()
		{
			GlobalContext.Properties["se/n ..... /n //View Source file for more details /n }

10. Example

Project: csharp-driver
Source File: ConnectionTests.cs
[Test]
        public void ReadParse_Handles_UnComplete_Body()
        {
            var connectionM/n ..... /n //View Source file for more details /n }

11. Example

Project: Autofac
Source File: ConcurrentTests.cs
[Fact]
        public void WhenTwoThreadsInitialiseASharedInstanceSimultaneouslyViaChildLifetime_OnlyOneInstanceIsActivated()
        {
            int activationCount = 0;
            var results = new ConcurrentBag<object>();
            var exceptions = new ConcurrentBag<Exception>();

            var builder = new ContainerBuilder();
            builder.Register(c =>
                {
                    Interlocked.Increment(ref activationCount);
                    Thread.Sleep(500);
                    return new object();
                })
                .SingleInstance();

            var container = builder.Build();

            ThreadStart work = () =>
            {
                 try
                 {
                     var o = container.BeginLifetimeScope().Resolve<object>();
                     results.Add(o);
                 }
                 catch (Exception ex)
                 {
                     exceptions.Add(ex);
                 }
            };

            var t1 = new Thread(work);
            var t2 = new Thread(work);
            t1.Start();
            t2.Start();
            t1.Join();
            t2.Join();

            Assert.Equal(1, activationCount);
            Assert.Empty(exceptions);
            Assert.Equal(1, results.Distinct().Count());
        }

12. Example

Project: msgpack-rpc-cli
Source File: TcpClientTransportTest.cs
private static void TestSendNotifyCore( IPEndPoint endPoint, CountdownEvent arrivalLatch, IProducerC/n ..... /n //View Source file for more details /n }

13. Example

Project: msgpack-rpc-cli
Source File: UdpClientTransportTest.cs
private static void TestSendNotifyCore( IPEndPoint endPoint, CountdownEvent arrivalLatch, IProducerC/n ..... /n //View Source file for more details /n }

14. Example

Project: msgpack-rpc-cli
Source File: TcpClientTransportTest.cs
private static void TestSendReceiveRequestCore( IPEndPoint endPoint, int count, int concurrency )
		/n ..... /n //View Source file for more details /n }

15. Example

Project: msgpack-rpc-cli
Source File: UdpClientTransportTest.cs
private static void TestSendReceiveRequestCore( IPEndPoint endPoint, int count, int concurrency )
		/n ..... /n //View Source file for more details /n }