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

  • SEARCH
  • Home
  • 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 6755065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:21:21+00:00 2026-05-26T13:21:21+00:00

Okay so here’s the thing: I have a linq query which loads approx. 1000

  • 0

Okay so here’s the thing:

I have a linq query which loads approx. 1000 lines into a variable, during that process I want to display a progressbar, not necessarily stating the percentage, can be marquee style, doesnt matter.

This progressbar is on a modal form to precent the user from interacting with the app for the time the query’s running.

Now here’s my code:

Private Sub LoadBar()
  Try
     Dim load As New frmLoadbar
     load.Text = "Loading bunch of data..."
     load.ShowDialog()
  Catch e As Threading.ThreadAbortException
     Threading.Thread.ResetAbort()
  End Try
End Sub

In another sub:

Dim myThreadDelegate As New Threading.ThreadStart(AddressOf LoadBar)
Dim th As New Threading.Thread(myThreadDelegate)
th.Name = "TimeConsuming"
th.Start()
Dim XY = db.Table.GetEnumerator
While XY.MoveNext
    Dim item As New ListViewItem
    item.Text = XY.Current.Name
    item.Tag = XY.Current
    ListBox1.Items.Add(item)
End While
Autos.Dispose()
Try
    th.Abort()
Catch ex As Exception //here's where i 'swallow the re-thrown exception
End Try

Not thats one of the ugliest code i’ve ever written.It works i just dont want that rethrown exception.
Some explanation:

  • I want the modal form to close after the query is done.
  • For that reason I ‘abort’ the thread running the form.
  • Since aborting a thread throws a double-exception i have to ‘swallow’
    that exception.

Now i know i could implement this like the following:

  • Coding a loop into the form holding the progressbar, which checks
    periodically for a boolean’s value, and if its true the form could
    close itself.
  • From the other form – on the worker thread – i could change that
    booleans value to true after the query’s finished.

But here comes my question:

Whats the best way to implement this?

  1. I know it can be done with a background worker, which has been
    specifically invented for this reason, but can i use the background
    worker as the thread to show the progressbar?
  2. If not (and i have to run the query on the background worker and
    showing the modal form from my original form), would that mean that
    the query would “work in the background”?
  3. Would that mean that the query would be slower?

I’ve looked into other tutorials, but for one reason or another, either i wasnt able to copy it (due to complexity) or I wasn’t convinced that it was better than this.

Thank you for your time you took to answer.

  • 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-26T13:21:22+00:00Added an answer on May 26, 2026 at 1:21 pm

    Okay, so for future reference, if someone needs clear help with code samples, Microsoft has it (thats a first..)

    You can download it here:

    Multithreading

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

Sidebar

Related Questions

Okay here is the scenario! I have a Person object which has an Address
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay here is what I'm trying to do: I have a model object that
Okay basically here's where I'm at. I have a list of PropertyDescriptor objects. These
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, here's the situation: We have a table of about 50 columns (created by
I have a Canvas on which I am drawing lines bewteen points in a
Okay so here is the problem I am having. I have several unit tests
Okay here's the program I have typed up(stdio.h is included also): /* function main
Okay so here is my database: I have a page on my .net form

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.