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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:56:36+00:00 2026-06-12T16:56:36+00:00

I am developing a .Net 4.0 C# Windows Service based (Dropbox like ) application

  • 0

I am developing a .Net 4.0 C# Windows Service based (Dropbox like ) application which runs continuously and keeps a watch on a specific folder for content and updates and notify the changes onto the Database and similar clients application will be installed on other machines as well which will perform suitable updates to the same folder in their hosting machines. I have developed the whole application with multiple threads and recursion calls which will keep on performing and notifying the changes through-out. The application runs well for 3 hrs after 3 hrs it throws in a stack-overflow exception and crashes.

To be more specific I have 9 threads and some of them do the following jobs

1) threadFSWToDB – write any file changes(add,rename,delete) to DB.

2) threadDBToUploadLogList – creates a folder on the server where the other clients will download file from.

3) threadDoUpload – will upload file on the web server.

4) threadDBToDownloadList – will upload a list of changes to be performed by polling DB.

my question is, is this the feasible solution or do I need to re-consider my design for the whole app. If yes what would be the best way to perform the above tasks (sequential or parallel). And what is the most basic approach for performing the tasks which are never ending and continuous in nature like this one.

My Code is as below, I don’t know how much to put in so that it could make the matter clear

Thread threadFSWToDB = new Thread(() => WriteFSWLogListToDatabase());


private static void WriteFSWLogListToDatabase()
    {
        try
        {
            using (var objEntities = new ShareBoxEntities()) // EF class instantiation
            {
// this DB class constructor call later on throws stack overflow exception not necessarily from this method
                var objConnector = new DBConnector(objEntities); 
                var objConnector = new DBConnector();
                List<string> directories = objConnector.GetAllSharedDirectoryRelativePaths();
                if (FSWLogList != null && FSWLogList.Count() > 0)
                {
                    for (int i = 0; i <= FSWLogList.Count - 1; i++)
                    {

            // some file changes being written to Database
                            FSWLogList[i].SavedInDB = true;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
    // write to event log and mail to administrator
        }
        finally
        {
            if (FSWLogList != null && FSWLogList.Count > 0)
            {
                FSWLogList.RemoveAll(item => item.SavedInDB == true);
            }
            Thread.Sleep(5000);
            WriteFSWLogListToDatabase();
        }
    }

if recursion is the main reason then why the application runs fine for some times a day or two and then starts exhibiting the above mentioned behaviour

  • 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-12T16:56:37+00:00Added an answer on June 12, 2026 at 4:56 pm

    Thanks everyone for their valuable time.

    I have found out the solution to my problem, the recursive function calls have been replaced with a while(true) //loop
    still being called on the respective threads
    This ensure that my function which monitors the folder doesn’t complete its execution while a try and catch ensured it goes on even after an exception. The problem that I faced while using the while(true) was any resource used in a function was to be made available for the other functions running on separate thread, that was handled by calling the thread.sleep for a specific period. It may not be a universal solution to a similar problem but it fitted my requirement, so I would like others to just watch out before implementing the stated solution in a similar scenario.

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

Sidebar

Related Questions

I am developing large data collecting ASP.Net/Windows service application-pair that uses Microsoft SQL Server
I'm developing a Windows Service in VB.NET 2008, but I feel like I'm going
I'm developing C# .NET windows Forms application. In which I've a main window and
I am developing an application which is web-based (asp.net MVC). The user configures reminders
I'm developing and application that runs as a Windows service. There are other components
I am developing a windows service which starts listenning the bluetooth connection using InTheHand.Net.Bluetooth
I am developing a .NET Windows service that is creating a couple of threads
I am Developing Windows Form Application in .Net, I want to insert selected rows
I am developing a simple ASP.Net application on a Windows 7 x64 machine using
I'm developing an winform application for Windows Mobile 5.0 and above. I'm using .Net

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.