my criteria is
i have to insert thousands or more records using asp.net
what i want to do is ...
let insert process going on and meanwhile i want to jump to other pages
or do some other activity while insert process is going on...
thanks in advance
i have to insert thousands or more records using asp.net
what i want to do is ...
let insert process going on and meanwhile i want to jump to other pages
or do some other activity while insert process is going on...
thanks in advance
Sunny SharmaPosted May 25, 2013, 5:13 AM
You can do this for sure. You can start a task that will keep running in background and you can perform some other task meanwhile.
Below is sample snippet of the code that you need.
===========================================
bool run = true; // to control the exit from the loops
Task.Factory.StartNew(()=>{
while(run)
{
... // your code here
}
});
======================================
This thread will keep running forever until run is true;
You can also use a try..catch block inside the snippet to catch any unexpected/anticipated error.
Please don't forget top accept this as answer if it helps you!
Thanks.