private void AddDiagnosticsInBackgroundLoop( int count, CosmosDiagnosticsContext cosmosDiagnostics, ConcurrentStack <Exception> concurrentStack) { CosmosDiagnosticsContext cosmosDiagnostics2 = new CosmosDiagnosticsContextCore( nameof(ValidateDiagnosticsAppendContext), "MyCustomUserAgentString"); Random random = new Random(); cosmosDiagnostics2.GetOverallScope().Dispose(); for (int i = 0; i < count; i++) { try { cosmosDiagnostics.AddDiagnosticsInternal(cosmosDiagnostics2); } catch (Exception e) { concurrentStack.Append(e); } } }