Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4006358
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:30:18+00:00 2026-05-20T08:30:18+00:00

I start a long operation (usually long query (SELECT) to database). It might take

  • 0

I start a long operation (usually long query (SELECT) to database).
It might take long time, and I want to add capability to stop this action.
Code looks like:

ThreadPool.QueueUserWorkItem(a => action.DoLongAction());

public void DoLongAction()
{
    var sql = Tables.Where(el => el.Some == "XXX"); // dynamically constructed LINQ query to database
    var result = db.Query(sql);
}

I can’t use signals of flags, to stop this thread. Because, long operation isn’t in my code, but in database process (sql query about 5 mins).

How can I stop this thread correctly?

UPD1. Not plain SQL, but LINQ (EF4, BLToolkit)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:30:19+00:00Added an answer on May 20, 2026 at 8:30 am

    If you really need to abort this Thread manually, then you can use the Thread class.
    For details about how to use it, you can look at this online resource.

    Please note that usually, using Thread.Abort(); is not a best practice, except when you are ending your program and wants to terminate all the running threads.

    In your case, as you are trying to end a SQL query, you should look at other ways to stop it (SqlCommand.Cancel(), ISession.CancelQuery(), …)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For quite a long time I've wanted to start a pet project that will
/* I start with this: */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> </Report> /*
When performing a long operation in your application, how do you promote information from
Long post.. sorry I've been reading up on this and tried back and forth
i am trying to implement a timeout on my database querys...so if an operation
I have a process that runs long, and I want to update a label
If I hit a page which calls session_start() , how long would I have
Start a new Silverlight application... and in the code behind (in the Loaded event),
I start by creating a string variable with some non-ascii utf-8 encoded data on
I start to write a client - server application using .net (C#) for both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.