For reference, I assume the following solution to my problem:
foreach(var category in categories) { foreach(var word in words) { var waitCallback = new WaitCallback(state => { var kv = (KeyValuePair<string, string>)state; DoSomething(kv.Key, kv.Value); }); var state2 = new KeyValuePair<string, string>(word, category); ThreadPool.QueueUserWorkItem(waitCallback, state2); } }
source share