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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:07:37+00:00 2026-05-20T11:07:37+00:00

Problem is that application closes without any error, VS stays opened. I have multiple

  • 0

Problem is that application closes without any error, VS stays opened.
I have multiple dynamically created FileSystemWatchers, all of them have eventhandler on “Created” event. So this eventhandler method looks like this :

void watcher_FileCreated(object sender, FileSystemEventArgs e)
{
    FileInfo f1 = new FileInfo(e.FullPath);
    filesDataGrid.Rows.Add(f1.Name);
    foreach (TLPclass table in parameterForm.getParameters)
    {
       //uses some funcion form another class
    }
}

Line which causes program to close is the one where I’m adding File name to DataGridView - filesDataGrid.Rows.Add(f1.Name);
Also runs OK without that line.
Weird thing is that application runs normally, when launched from .exe file in projects folder. I can’t see error in my code, but I guess theres something awfully wrong with it, if it doesn’t even show error message.
And – what are the most common reasons why program could just shut down with no warnings?

  • 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-20T11:07:38+00:00Added an answer on May 20, 2026 at 11:07 am

    The FileSystemWatcher will trigger the events in a separate thread. The logic inside the event handlers will need to take that fact in consideration and perform any synchronization needed. So you’ll need something like this:

    private void watcher_FileCreated(object sender, FileSystemEventArgs e)
    {
        if (filesDataGrid.InvokeRequired)
        {
            filesDataGrid.Invoke((MethodInvoker)delegate { watcher_FileCreated(sender, e); });
        }
        else
        {
            FileInfo f1 = new FileInfo(e.FullPath);
            filesDataGrid.Rows.Add(f1.Name);
            foreach (TLPclass table in parameterForm.getParameters)
            {
               //uses some funcion form another class
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here is the problem that I am facing: I have an application that
I'm facing a problem that drives me crazy, I created a java application using
I have a problem with my android application. That application which uses the kSOAP
Problem I have a UDPlistener application that I need to write a unit test
The problem: we have one application that has a portion which is used by
My application is closing without any error messages and re-launching automatically after switching activities
I'm currently working a problem that requires my web application to generate a chart
I'm running in to a problem that I was able to fix with Application.DoEvents,
Problem I want to create an application that can be extended somehow by programmers.
The problem is that in a 32-bit application on Mac OS X I receive

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.