using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
public static async void Main()
string[] firmaListesi = new string[]{ "AK", "ALLIANZ" };
var tasks = new List<Task>();
var list = new List<KeyValuePair<string, string>>();
foreach (var line in firmaListesi)
if (!string.IsNullOrEmpty(line))
list.Add(new KeyValuePair<string, string>("EcryptedHeaderID", "EID"));
list.Add(new KeyValuePair<string, string>("InsuranceFirm", line));
Console.WriteLine(list.FirstOrDefault(x => x.Key == "EcryptedHeaderID"));
tasks.Add( Task.Run(async () => { RunComplementaryHealth(line, list); }));
list.Remove(list.FirstOrDefault(x => x.Key == "InsuranceFirm"));
list.Remove(list.FirstOrDefault(x => x.Key == "EcryptedHeaderID"));
Task t = Task.WhenAll(tasks);
public static async Task RunComplementaryHealth(string line, List<KeyValuePair<string, string>> list) {
Console.WriteLine("ASYNC ÇALIŞTIĞINDA");
Console.WriteLine("HEADERID ASYNC: " + list.FirstOrDefault(x => x.Key == "InsuranceFirm"));