Click here to Skip to main content
15,442,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi guys,
I have created a solution for the following question:
Click here to see the details of the question
C#
int[] Inventory = new int[UniqueISBN.Length];
OleDbConnect.Open();
Parallel.For(0, UniqueISBN.Length, Index =>
{
    OleDbCommand_Update.CommandText = string.Join(null, "Select Count(*) From BookTable Where ISBN = '", UniqueISBN[Index], "'");
    Inventory[Index] = (int)OleDbCommand_Update.ExecuteScalar();
    OleDbCommand_Update.CommandText = string.Join(null, "Update BookTable Set Inventory = ", Inventory[Index], " Where ISBN = '", UniqueISBN[Index], "'");
    OleDbCommand_Update.ExecuteNonQuery();
}
);
Parallel.For(0, UniqueISBN.Length, Index =>
{
    EnumerableRowCollection<DataRow> Query = from Row in BookDataView.Table.AsEnumerable() where Row.Field<string>("ISBN") == UniqueISBN[Index] select Row;
    Parallel.ForEach(Query, Row =>
    {
        Row["Inventory"] = Inventory[Index];
    }
    );
}
);
OleDbConnect.Close();

But when I delete multiple rows, I get the following error:
Managed Debugging Assistant 'RaceOnRCWCleanup' : 'An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.'

What caused this error and how can it be fixed?
I use the following tools:
.NET Framework 4.5.2, WPF
Thanks.

What I have tried:

Click to see what I tried
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900