Hi,
In C# (.NET), I got 2 loops ->
A for ... do:
{
B for do:
{ something}
something that evaluates all "for"s in B loop
}
I used Parallel.For for the inner loop but the results of those loops varied every time I ran the application. I think it may be a result of Some asynchrounous work, but I am not sure how to be sure about it in VS 2005 Express, moreover I am not sure If I am supposed to do something Like "Wait until Parallel.For is finished, then do the stuff for all of it.
EDIT (due to comment which requests some more specific information):
for (int i = 0; i < max; i++) //Pre Vsetky retazce ..
{
prefix = 0;
tempsame.Clear();
bool spracovane = true;
int dlzkaI = Items[i, 1].Length;
if (Items[i, 2] != "1") { spracovane = false; }
if (spracovane == false)
// Parallel.For(0, max, delegate(int j)
// {
for (int j = 0; j < max; j++) //Pre kazdy dalsi
{
int dlzkaJ = Items[j, 1].Length;
if (dlzkaJ >= dlzkaI)
{
CompareInfo myComp = CultureInfo.InvariantCulture.CompareInfo;
bool isprefix = myComp.IsPrefix(Items[j, 1], Items[i, 1]);
bool issame = false;
if (dlzkaJ.Equals(dlzkaI)) issame = true;
if (isprefix == true && issame == false)
{
prefix++;
}
else if (isprefix == true && issame == true && prefix == 0)
{
tempsame.Add(Items[j, 0]);
}
}
}
if ((prefix==0) && (spracovane==false))
{
Items = UpdateUnique(tempsame.ToArray(typeof(string)) as string[], Items);
unique++;
}
}
In short, the 2 loops loop through same array of strings and choose only unique strings -> it means that the string can't be a prefix to any other string.
> Car - unique Car - unique Cafeteria -
> unique Automobile - unique Auto - not
> unique - it's prefix of Automobile
> Auto - not unique
EDIT: No other suggestions?