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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:08:46+00:00 2026-06-15T08:08:46+00:00

I have a queue , it receives data overtime. I used multi thread to

  • 0

I have a queue , it receives data overtime.
I used multi thread to dequeue and save to database.
I create an Array of Thread to do this job.

for (int i = 0; i < thr.Length; i++)
{
    thr[i] = new Thread(new ThreadStart(SaveData));
    thr[i].Start();
}

SaveData

Note : eQ and eiQ is 2 global queue. I used while to keep thread alive.

public void SaveData()
{

    var imgDAO = new imageDAO ();
    string exception = "";
    try
    {
        while (eQ.Count > 0 && eiQ.Count > 0)
        {
            var newRecord = eQ.Dequeue();
            var newRecordImage = eiQ.Dequeue();                        

            imageDAO.SaveEvent(newEvent, newEventImage);

            var storepath = Properties.Settings.Default.StorePath;
            save.WriteFile(storepath, newEvent, newEventImage);
        }
    }
    catch (Exception e)
    {                
        Global._logger.Info(e.Message + e.Source);
    }
}

It did create multi thread but when I debug, only 1 thread alive, the rest is dead.
I dont know why ? Any one have idea? Tks

  • 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-15T08:08:47+00:00Added an answer on June 15, 2026 at 8:08 am

    You are using WriteFile in that thread function.

    Is this possible, that you trying to write file that may be locked by another thread (same filename or something)?

    And one more thing – saving data on disk by multiple threads – i dont like it.

    I think you should create some buffer instead of many threads and write it every few records/entries.

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

Sidebar

Related Questions

I have a class containing a worker thread which receives data from a queue
I have a view that receives new data from a secondary thread. Every time
I have a class called 'subscribedQueue'. This class receives its data via its subscribed
Here I have to send and receive dynamic data using a SysV message queue.
I have a single AMQ queue that receives simple messages with string body. Consider
I have a queue structure that is being used by several pthreads. The threads
I have to send and receive dynamic data using a SysV message queue for
I am working with a core database to save my data that I get
I have a program that receives serial data and uses matplotlib to graph it
I have a process I run periodically on a background thread that receives changes

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.