In Windows Phone 7 / Silverlight, is the following code safe or is it a race condition?
//Snippet 1
foreach(var item in list)
{
Deployment.Current.Dispatcher.BeginInvoke( () => { foo(item); });
}
Surely (?) this alternative is racy?
//Snippet 2
Deployment.Current.Dispatcher.BeginInvoke( () =>
{
foreach(var item in list){ foo(item); }
});
list.Clear();