Here are the examples of the csharp api class System.Collections.Concurrent.ConcurrentBag.Add(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
68 Examples
0
1. Example
Project: log4net.ElasticSearch
Source File: ErrorHandlerStub.cs
Source File: ErrorHandlerStub.cs
public void Error(string message) { messages.Add(message); }
0
2. Example
Project: StopGuessing
Source File: DbUserAccountController.cs
Source File: DbUserAccountController.cs
public async Task<CloudTable> GetTableAsync(string tableName, CancellationToken cancellationToken = default(CancellationToken)) { // Create the table client. CloudTableClient tableClient = CloudStorageAccountForTables.CreateCloudTableClient(); // Retrieve a reference to the table. CloudTable table = tableClient.GetTableReference(tableName); // Create the table if it doesn't exist. // remove to optimize if (!TablesKnownToExist.Contains(tableName)) { await table.CreateIfNotExistsAsync(cancellationToken); TablesKnownToExist.Add(tableName); } return table; }
0
3. Example
Project: STSdb4
Source File: UsersAndExceptionHandler.cs
Source File: UsersAndExceptionHandler.cs
public void Disconnect(ListView.SelectedListViewItemCollection clientsForDisconnect) { if (IsWorking) { foreach (var client in clientsForDisconnect) ClientsForDisconnects.Add(((ListViewItem)client).Text); Disconnecting = true; } }
0
4. Example
Project: SharpCraft-retired-
Source File: ConcurrentBagListener.cs
Source File: ConcurrentBagListener.cs
public override void Write(String message) { var indent = String.Empty; if (this.isNewline) indent = new String(' ', this.IndentSize * this.IndentLevel); this.Messages.Add(indent + message); this.isNewline = false; }
0
5. Example
Project: ultraviolet
Source File: ExpressionCompiler.cs
Source File: ExpressionCompiler.cs
private static ConcurrentBag<String> GetDefaultReferencedAssemblies() { var referencedAssemblies = new ConcurrentBag<String>(); referencedAssemblies.Add("System.dll"); referencedAssemblies.Add(typeof(Contract).Assembly.Location); referencedAssemblies.Add(typeof(UltravioletContext).Assembly.Location); referencedAssemblies.Add(typeof(PresentationFoundation).Assembly.Location); return referencedAssemblies; }
0
6. Example
Project: Smocks
Source File: AppDomainContext.cs
Source File: AppDomainContext.cs
public void RegisterForDeletion(string location) { _filesToDelete.Add(location); }
0
7. Example
Project: routemeister
Source File: SyncDispatcherTests.cs
Source File: SyncDispatcherTests.cs
public void Handle(ConcreteMessageA message) { message.Data.Add($"{GetType().Name}.{nameof(Handle)}<{message.GetType().Name}>"); }
0
8. Example
Project: routemeister
Source File: SyncDispatcherTests.cs
Source File: SyncDispatcherTests.cs
public void Handle(ConcreteMessageB message) { message.Data.Add($"{GetType().Name}.{nameof(Handle)}<{message.GetType().Name}>"); }
0
9. Example
Project: ScalableJoins
Source File: Program.cs
Source File: Program.cs
public void put(PAYLOAD s) { q.Add(s); }
0
10. Example
Project: log4net.ElasticSearch
Source File: ErrorHandlerStub.cs
Source File: ErrorHandlerStub.cs
public void Error(string message, Exception e) { exceptions.Add(e); messages.Add(message); }
0
11. Example
Project: dotnet-apiport
Source File: ProjectBuilder2015.cs
Source File: ProjectBuilder2015.cs
private async Task<IEnumerable<string>> GetBuildOutputFilesFromCPSAsync( Pro/n ..... /n //View Source file for more details /n }
0
12. Example
Project: NLog
Source File: WebServiceTargetTests.cs
Source File: WebServiceTargetTests.cs
public IEnumerable<string> Get(string param1 = "", string param2 = "") { RecievedLogsGetParam1.Add(param1); if (CountdownEvent != null) { CountdownEvent.Signal(); } return new string[] { "value1", "value2" }; }
0
13. Example
Project: NLog
Source File: WebServiceTargetTests.cs
Source File: WebServiceTargetTests.cs
public void Post([FromBody] ComplexType complexType) { //this is working. if (complexType == null) { throw new ArgumentNullException(nameof(complexType)); } RecievedLogsPostParam1.Add(complexType.Param1); if (CountdownEvent != null) { CountdownEvent.Signal(); } }
0
14. Example
Project: abplus
Source File: DefaultInMemoryMessageTracker.cs
Source File: DefaultInMemoryMessageTracker.cs
public Task MarkAsProcessed(string processId) { InMemoryStore.Add(processId); return Task.FromResult(0); }
0
15. Example
Project: Sharpmake
Source File: Project.cs
Source File: Project.cs
private void ReportError(string message, bool onlyWarn = false) { if (_alreadyReported.Contains(message)) return; _alreadyReported.Add(message); if (onlyWarn) { Builder.Instance.LogWarningLine(message); } else { Builder.Instance.LogErrorLine(message); } }
0
16. Example
Project: Wyam
Source File: ValidateLinks.cs
Source File: ValidateLinks.cs
private static void AddOrUpdateFailure(ConcurrentBag<Tuple<FilePath, string>> links, ConcurrentDictionary<FilePath, ConcurrentBag<string>> failures) { foreach (Tuple<FilePath, string> link in links) { failures.AddOrUpdate(link.Item1, _ => new ConcurrentBag<string> { link.Item2 }, (_, list) => { list.Add(link.Item2); return list; }); } }
0
17. Example
Project: Cirqus
Source File: TestConcurrentBag.cs
Source File: TestConcurrentBag.cs
[Test, Ignore("oh, it does")] public void DoesNotContainMultipleInstancesOfTheSameObject() { var baggerino = new ConcurrentBag<string>(); baggerino.Add("hej"); baggerino.Add("med"); baggerino.Add("dig"); baggerino.Add("dig"); baggerino.Add("dig"); baggerino.Add("dig"); Assert.That(baggerino.Count, Is.EqualTo(3)); }
0
18. Example
Project: routemeister
Source File: AsyncDispatcherTests.cs
Source File: AsyncDispatcherTests.cs
public Task HandleAsync(ConcreteMessageA message) { message.Data.Add($"{GetType().Name}.HandleAsync<{message.GetType().Name}>"); return Task.FromResult(0); }
0
19. Example
Project: routemeister
Source File: AsyncDispatcherTests.cs
Source File: AsyncDispatcherTests.cs
public Task HandleAsync(ConcreteMessageB message) { message.Data.Add($"{GetType().Name}.HandleAsync<{message.GetType().Name}>"); return Task.FromResult(0); }
0
20. Example
Project: routemeister
Source File: MiddlewareEnabledAsyncRouterTests.cs
Source File: MiddlewareEnabledAsyncRouterTests.cs
public Task HandleAsync(ConcreteMessageA message) { message.Data.Add($"{GetType().Name}.HandleAsync<{message.GetType().Name}>"); return Task.FromResult(0); }
0
21. Example
Project: routemeister
Source File: MiddlewareEnabledAsyncRouterTests.cs
Source File: MiddlewareEnabledAsyncRouterTests.cs
public Task HandleAsync(ConcreteMessageB message) { message.Data.Add($"{GetType().Name}.HandleAsync<{message.GetType().Name}>"); return Task.FromResult(0); }
0
22. Example
Project: routemeister
Source File: SequentialAsyncRouterTests.cs
Source File: SequentialAsyncRouterTests.cs
public Task HandleAsync(ConcreteMessageA message) { message.Data.Add($"{GetType().Name}.HandleAsync<{message.GetType().Name}>"); return Task.FromResult(0); }
0
23. Example
Project: routemeister
Source File: SequentialAsyncRouterTests.cs
Source File: SequentialAsyncRouterTests.cs
public Task HandleAsync(ConcreteMessageB message) { message.Data.Add($"{GetType().Name}.HandleAsync<{message.GetType().Name}>"); return Task.FromResult(0); }
0
24. Example
Project: identitydocumentdb
Source File: Program.cs
Source File: Program.cs
private static async Task ConfirmUserConvert(TempUser user, UserStore<IdentityUser> store) { var userFound = await store.FindByIdAsync(user.User.Id); if (userFound.Roles.Where(r => user.Roles.Any(ur => ur.Id == r.Id)).Count() == user.Roles.Count && userFound.Claims.Where(c => user.Claims.Any(uc => uc.Id == c.Id)).Count() == user.Claims.Count && userFound.Logins.Where(l => user.Logins.Any(ul => ul.Id == l.Id)).Count() == user.Logins.Count) { Interlocked.Increment(ref iUserSuccessConvert); Console.WriteLine("Completed User: {0}", user.User.Id); } else { Interlocked.Increment(ref iUserFailureConvert); userIdFailures.Add(user.User.Id); } }
0
25. Example
Project: StopGuessing
Source File: DbUserAccountController.cs
Source File: DbUserAccountController.cs
public async Task<CloudTable> GetTableAsync(string tableName, CancellationToken cancellationToken = default(CancellationToken)) { // Create the table client. CloudTableClient tableClient = CloudStorageAccountForTables.CreateCloudTableClient(); // Retrieve a reference to the table. CloudTable table = tableClient.GetTableReference(tableName); // Create the table if it doesn't exist. // remove to optimize if (!TablesKnownToExist.Contains(tableName)) { await table.CreateIfNotExistsAsync(getTableRequestOptions(), getOperationContext(), cancellationToken); TablesKnownToExist.Add(tableName); } return table; }
0
26. Example
Project: Glass.Mapper
Source File: HttpCache.cs
Source File: HttpCache.cs
protected override void InternalAddOrUpdate <T>(string key, T value) { var cache = Cache; if (cache == null) return; if (AbsoluteExpiry > 0) { cache.Insert(key, value, null, DateTime.Now.AddSeconds(AbsoluteExpiry), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } else { cache.Insert(key, value, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, SlidingExpiry), CacheItemPriority.Normal, null); } // duplicate keys here don't matter Keys.Add(key); }
0
27. Example
Project: DDD.Enterprise.Example
Source File: TimeSeries.cs
Source File: TimeSeries.cs
public async Task<bool> SaveMetric(string streamId, string name, object value, long timestamp, IDictionary<string, string> tags) { var quantum = new Quantum { Name = name, Tags = tags ?? new Dictionary<string, string>(), Timestamp = timestamp, Duration = "x" }; var success = await UpdateTimeDb(streamId, (timedb) => { timedb = timedb.TryAdd(quantum, x => x.Id); return timedb; }).ConfigureAwait(false); if (!success) { _logger.Error("Failed to add new quantum id {0} to timedb", quantum.Id); return false; } _updatedNames.Add(streamId); return true; }
0
28. Example
Project: corral
Source File: Program.cs
Source File: Program.cs
static ConcurrentBag<string> Shuffle(ConcurrentBag<string> bag) { var b = new List<string>(bag); var ret = new ConcurrentBag<string>(); var rand = new Random(); while (b.Count != 0) { var r = rand.Next(b.Count); ret.Add(b[r]); b.RemoveAt(r); } return ret; }
0
29. Example
Project: Alluvial
Source File: DatabaseSetupTests.cs
Source File: DatabaseSetupTests.cs
[Test] public async Task Alluvial_leases_can_be_initialized_using_an_ItsDomainSql_migration() { var leasables = LeasableFruits(); var pool = "fruits"; using (var db = new SchemaTestDbContext()) { new CreateAndMigrate<SchemaTestDbContext>().InitializeDatabase(db); var migrator = new AlluvialDistributorLeaseInitializer<string>( leasables, pool); db.EnsureDatabaseIsUpToDate(migrator); } // assert by running a distributor and seeing that the expected leases can be obtained var distributor = new SqlBrokeredDistributor<string>( leasables, new SqlBrokeredDistributorDatabase(SchemaTestDbContext.ConnectionString), pool); var received = new ConcurrentBag<string>(); distributor.OnReceive(async l => received.Add(l.Resource)); await distributor.Distribute(3).Timeout(); received.Should().Contain(leasables.Select(l => l.Resource)); }
0
30. Example
Project: Flux
Source File: HttpClientGetTest.cs
Source File: HttpClientGetTest.cs
[Fact] public void TenConcurrentSimpleGet() { var server = new Server(3002); server.Start(Application.Run); var uri = new Uri("http://localhost:3002/"); var bag = new ConcurrentBag<string>(); const int count = 10; for (int i = 0; i < count; i++) { var client = new WebClient(); client.DownloadStringCompleted += (sender, args) => { bag.Add(args.Result); client.Dispose(); }; client.DownloadStringAsync(uri); } SpinWait.SpinUntil(() => bag.Count == count); server.Stop(); Assert.Equal(count, bag.Count); int iteration = 0; foreach (var actual in bag) { Assert.Equal(Index.Html, actual); } }
0
31. Example
Project: Flux
Source File: HttpClientGetTest.cs
Source File: HttpClientGetTest.cs
[Fact] public void OneHundredConcurrentSimpleGet() { var server = new Server(3003); server.Start(Application.Run); var uri = new Uri("http://localhost:3003/"); var bag = new ConcurrentBag<string>(); const int count = 100; for (int i = 0; i < count; i++) { var client = new WebClient(); client.DownloadStringCompleted += (sender, args) => { bag.Add(args.Result); client.Dispose(); }; client.DownloadStringAsync(uri); } SpinWait.SpinUntil(() => bag.Count == count, 10000); server.Stop(); Assert.Equal(count, bag.Count); foreach (var actual in bag) { Assert.Equal(Index.Html, actual); } }
0
32. Example
Project: dotnet-apiport
Source File: ProjectAnalyzer.cs
Source File: ProjectAnalyzer.cs
public async Task AnalyzeProjectAsync(ICollection<Project> projects, CancellationToken cancell/n ..... /n //View Source file for more details /n }
0
33. Example
Project: ultraviolet
Source File: ExpressionCompiler.cs
Source File: ExpressionCompiler.cs
private static CompilerResults PerformExpressionVerificationCompilationPass(ExpressionCompilerState state, IEnumerable<DataSourceWrapperInfo> models, ConcurrentBag<String> referencedAssemblies) { Parallel.ForEach(models, model => { referencedAssemblies.Add(model.DataSourceType.Assembly.Location); foreach (var reference in model.References) { referencedAssemblies.Add(reference); } foreach (var expression in model.Expressions) { expression.GenerateGetter = true; expression.GenerateSetter = false; } WriteSourceCodeForDataSourceWrapper(state, model); }); return CompileDataSourceWrapperSources(state, null, models, referencedAssemblies); }
0
34. Example
Project: DDD.Enterprise.Example
Source File: TimeSeries.cs
Source File: TimeSeries.cs
public async Task<bool> SaveMetrics(string streamId, IEnumerable<Datapoint> metrics) { var quantums = metrics.Select(x => new Quantum { Name = x.Name, Tags = x.Tags ?? new Dictionary<string, string>(), Timestamp = x.Timestamp, Duration = "x" }); var success = await UpdateTimeDb(streamId, (timedb) => { quantums.ForEach(x => timedb = timedb.TryAdd(x, y => y.Id)); return timedb; }).ConfigureAwait(false); if(!success) _logger.Error("Failed to add new quantums to timedb {0}", streamId); _updatedNames.Add(streamId); return success; }
0
35. Example
Project: ImGui
Source File: TextFileWriter.cs
Source File: TextFileWriter.cs
public void WriteText( string text, bool flush ) { cache.Add( text ); if ( flush ) Flush(); else { if ( flushTask == null ) CreateFlushTask( TimeSpan.FromSeconds( 10 ) ); } }
0
36. Example
Project: Alluvial
Source File: DistributorTests.cs
Source File: DistributorTests.cs
[Test] public async Task Unless_work_is_completed_then_lease_is_not_reissued_before_its_duration_has_passed() { var leasesGranted = new ConcurrentBag<string>(); var distributor = CreateDistributor(async l => { Console.WriteLine("GRANTED: " + l); leasesGranted.Add(l.ResourceName); if (l.ResourceName == "2") { await Task.Delay(((int) DefaultLeaseDuration.TotalMilliseconds*6)); } }); await distributor.Start(); await Task.Delay((int) (DefaultLeaseDuration.TotalMilliseconds*.5)); await distributor.Stop(); await Task.Delay(100); leasesGranted.Should().ContainSingle(l => l == "2"); }
0
37. Example
Project: ME3Explorer
Source File: Texplorer2.cs
Source File: Texplorer2.cs
private ConcurrentBag<string> ScanPCCList(bool isTree, List<string> pccs = null) /n ..... /n //View Source file for more details /n }
0
38. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Time formatting works correctly for all combinations of hours, format s/n ..... /n //View Source file for more details /n }
0
39. Example
Project: Elasticsearch-Azure-PAAS
Source File: ElasticsearchManager.cs
Source File: ElasticsearchManager.cs
protected virtual Task DownloadAdditionalPlugins() { _pluginArtifactPaths = new ConcurrentBag<string>(); var processSources = _sources.Select(s => Task.Run(s).ContinueWith((source) => { foreach (var artifact in source.Result) { var filePath = Path.Combine(_archiveRoot, artifact.Name); _pluginArtifactPaths.Add(filePath); if (!File.Exists(filePath)) { Task.Factory.StartNew(() => { artifact.DownloadTo(filePath); }, TaskCreationOptions.AttachedToParent); } } })); return Task.WhenAll(processSources); }
0
40. Example
Project: BaiduCloudSupport
Source File: MainWindow.xaml.cs
Source File: MainWindow.xaml.cs
private async void button_GetDownloadURLSelected_Click(object sender, RoutedEventArgs e) { /n ..... /n //View Source file for more details /n }
0
41. Example
Project: httpclient-interception
Source File: InterceptingHttpMessageHandlerTests.cs
Source File: InterceptingHttpMessageHandlerTests.cs
[Fact] public static async Task SendAsync_Calls_OnSend_With_RequestMessage() { // Arrange var header = "x-request"; var requestUrl = "https://google.com/foo"; var options = new HttpClientInterceptorOptions() .Register(HttpMethod.Get, new Uri(requestUrl), () => Array.Empty<byte>()); int expected = 7; int actual = 0; var requestIds = new ConcurrentBag<string>(); options.OnSend = (p) => { Interlocked.Increment(ref actual); requestIds.Add(p.Headers.GetValues(header).FirstOrDefault()); return Task.CompletedTask; }; Task GetAsync(int id) { var headers = new Dictionary<string, string>() { [header] = id.ToString(CultureInfo.InvariantCulture) }; return HttpAssert.GetAsync(options, requestUrl, responseHeaders: headers); } // Act var tasks = Enumerable.Range(0, expected) .Select(GetAsync) .ToArray(); await Task.WhenAll(tasks); // Assert actual.ShouldBe(expected); requestIds.Count.ShouldBe(expected); requestIds.ShouldBeUnique(); }
0
42. Example
Project: identityazuretable
Source File: Program.cs
Source File: Program.cs
public static void Main(string[] args) { if (!ValidateArgs(args)) { /n ..... /n //View Source file for more details /n }
0
43. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Time parsing works correctly for all combinations of hours, format stri/n ..... /n //View Source file for more details /n }
0
44. Example
Project: ServiceBusExplorer
Source File: ServiceBusHelper.cs
Source File: ServiceBusHelper.cs
public EventData CreateEventDataTemplate(Stream stream, /n ..... /n //View Source file for more details /n }
0
45. Example
Project: nanoprofiler
Source File: ConcurrencyTest.cs
Source File: ConcurrencyTest.cs
[Test] [Repeat(100)] public void NanoProfilerWrapper_WritesReportWhenExitingRootSpan_SaveSessionCallbackAndTasks() { var reports = new ConcurrentBag<string>(); ProfilingSession.CircularBuffer = new CircularBuffer<ITimingSession>(200); ProfilingSession.ProfilingStorage = new NanoProfilerStorageInMemory(session => { reports.Add(GetReport(session)); }); const int count = 10; List<Task<string>> tasks = Enumerable.Range(1, count) .Select(i => Task.Run(DoWork)) .ToList(); Task.WhenAll(tasks).Wait(); // Due to running two tasks inside each thread, the call context seems a bit arbitrary // so the number of reports vary depending on whether it consider child1.1 and child1.2 // spans a child of the DoWork span or not. Assert.AreEqual(reports.Count, count); foreach (string report in reports) Assert.True(report.Contains("root = "), "report.Contains('root = ')"); }
0
46. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Date/time parsing works correctly for all combinations of months, forma/n ..... /n //View Source file for more details /n }
0
47. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Date/time parsing works correctly for all combinations of hours, format/n ..... /n //View Source file for more details /n }
0
48. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Date/time parsing works correctly for all combinations of milliseconds,/n ..... /n //View Source file for more details /n }
0
49. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Date parsing works correctly for all combinations of months, format str/n ..... /n //View Source file for more details /n }
0
50. Example
Project: Orchard
Source File: DefaultDateFormatterTests.cs
Source File: DefaultDateFormatterTests.cs
[Test] [Description("Date/time formatting works correctly for all combinations of months, fo/n ..... /n //View Source file for more details /n }