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 8791921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:54:33+00:00 2026-06-13T22:54:33+00:00

When trying to read data from mdb using backgroundworker I get an error The

  • 0

When trying to read data from mdb using backgroundworker I get an error

The program ‘[3768] BackgroundWorkerExample.vshost.exe: Managed’ has exited with code 0 (0x0).

without any other information or exception and I’m not able to catch it. Here is my code, without BGW it works fine. Do I miss something?

namespace BackgroundWorkerExample
{
public class TestClass
{
    BackgroundWorker _Worker;

    public TestClass()
    {
        InitializeWorker();
    }

    public void InitializeWorker()
    {
        _Worker = new BackgroundWorker();

        _Worker.DoWork += new DoWorkEventHandler(WorkerDoWork);
        _Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerRunWorkerCompleted);
    }

    private void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        Console.WriteLine("Work completed!");
    }

    private void WorkerDoWork(object sender, DoWorkEventArgs e)
    {
        DataTable data = GetDataTable();
        PrintResults(data);
    }

    public void Run()
    {
        _Worker.RunWorkerAsync();
    }

    public DataTable GetDataTable()
    {
        string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\students.mdb;";

        try
        {
            using (OleDbConnection con = new OleDbConnection(connectionString))
            {
                try
                {
                    con.Open(); // crashes here!

                    DataTable res = new DataTable();

                    string query = "SELECT * FROM students";

                    OleDbDataAdapter adapter = new OleDbDataAdapter(query, con);
                    adapter.Fill(res);

                    return res;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return null;
                }
            }
        }
        catch (Exception e)
        {
            // never reaches this part
            return null;
        }
    }

    public void PrintResults(DataTable data)
    {
        foreach (DataRow row in data.Rows)
        {
            for (int i = 0; i < 5; i++)
            {
                Console.Write(row[i] + "   ");
            }
            Console.WriteLine();
        }
    }
}
}
  • 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-06-13T22:54:34+00:00Added an answer on June 13, 2026 at 10:54 pm

    Looks like you are not giving enough time for the BackGroundWorker to execute.A quick fix would be to check if BackGroundWorker is busy.If it’s busy you can make your Main thread to wait for sometime so the background worker can complete its job.

    The message that you are seeing is not an error, but just an indication that the threads have closed down(primary and the background worker thread)

    public void Run()
    {
        _Worker.RunWorkerAsync();
    
         while (_Worker.IsBusy){
    
            Thread.Sleep(4000);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read encrypted struct data from file using fread(). once i get
I'm trying to read data from a server by using a GET URLRequest with
I'm trying to read data from excel using POI. How can I check if
I'm trying to read data from SQL Server database using Perl and the DBI
I am trying to read data from a bluetooth barcode scanner (KDC300) using C.
I am trying to read data from excel files using datatable. The command select
I'm trying to read data from 1.txt in my iphone project's resources folder using
I'm trying to read data from an Excel document in C# using Microsofts COM
I am trying to read in data from a text file using numpy.loadtxt with
I am specifically trying to read data from an SNMP port in python using

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.