简体   繁体   中英

Use KeyValuePair<String, String> in Parallel.ForEach

I want to run this normal loop in Parallel using Parallel.For or Parallel.ForEach<>

foreach (KeyValuePair<String, String> symbol in symbolsConfigured){..}

I've been using elsewhere like this -

Parallel.ForEach(sig.Products, dbp =>
            {...}

But I can't think of how to write this.

You do it exactly the same way:

Parallel.ForEach(symbolsConfigured, kvp =>
            {...});

The compiler will infer the callback's parameter type, just like any other call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM