Ruben Vera

Ruben Vera

  • NA
  • 3
  • 0

Problem Looping controls using Parallel.foreach

Jun 8 2010 6:23 AM

Hello,
i'm trying to loop through all my controls using Parallel.Foreach but i'm having some problems... I thought I was going to have no problems cause the ControlCollection class implements IEnumerable...
This is what I do without Parallel:
foreach
(Control c in ascx.Controls)
{
if (c is Dynamic.Controls.UnoN && UnaNaAcumulados.IndexOf(c.ID+",")==-1)
{
UnaNaAcumulados += c.ID +
",";
Control caux = (Control)this.LoadControl("~/Datos/UaN_" + c.ID + ".ascx");
UaNNames(caux);
}
}
And I'm trying to do the same with parallel, something like this:
Parallel
.ForEach<Control>(ascx.Controls, c => {
if (c is Dynamic.Controls.UnoN) {
UnaNaAcumulados += c.ID +
",";
Control caux = (Control)this.LoadControl("~/Datos/UaN_" + c.ID + ".ascx");
UaNNames(caux);
}
});

But it says that ControlCollection cannot be converted to OrderablePartitioner.
Any ideas?? I've been looking for some help but i'm stuck.
 
Thanks a lot in advance.

Answers (1)