I have a couple of worker functions that need to run in the background, so that the page isn't being held up (and I'm using a polled AJAX update panel).
I have considered using the BackgroundWorker class, but would like this to works as I have alot of code that is threaded in a classic manner.
The issue is that one of the worker functions, which deletes products, categories, manufacturers and vendors, when in another managed thread, doesn't work.
The function uses a simple:
Code: Select all
foreach (Product prod in Token.Instance.Store.Products)
{
++prodCount;
if (prod != null)
prod.Delete();
}
This function works if it is not threaded, that is, if it's in the code behind the button.
The Token.Instance.Store.Products collection is seemingly empty.
I have tried the following code before the foreach statements:
Code: Select all
Token.Instance.Store = new Store(StoreID);
But it still doesn't delete the items.
Any help is greatly appreciated,
The wall I'm banging my head against is getting sick of me.