Avatar of yadavdep
yadavdep
Flag for India asked on

Thread was being aborted

I am running a process from my asp.net application in a separate thread.
This process takes time as it has to insert 150000 records in the table.

But I am getting "Thread was being aborted" error some where around 6000 th  record only.

What can I do here to keep the running till all records gets imported.
C#ASP.NET.NET Programming

Avatar of undefined
Last Comment
Volox

8/22/2022 - Mon
kaufmed

Did you make the thread a background thread?

e.g.

Thread t = new Thread(SomeFunction);

t.IsBackground = true;

Open in new window

yadavdep

ASKER
No, I don't think I did that.

Also, I recheck the code and I guess it is running in the main thread only.

If it is running in the main thread then is there any solution to it
kaufmed

I suppose that depends on how you want to solve it. If you want to run it on the main thread, then your user's browser window is going to sit there spinning until the operation completes--assuming it completes before your configured timeout period. Otherwise, I *think* you would need to make the thread a background thread in order to allow ASP.NET to return a response to the client browser, yet still continue processing the DB inserts. This foregos returning a response to the browser in that request. You would have to work some AJAX magic in order to see a response from the background thread's work.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Volox

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.