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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:33:11+00:00 2026-05-25T22:33:11+00:00

we’re having an application on server instance and quite rarely, but we have out

  • 0

we’re having an application on server instance and quite rarely, but we have out of memory exception (program is not leaking, just instance is quite small and it operates with quite big amounts of data).

That would be not a problem, as we monitor processes on that server instance and if some of the processes are not found in process list, alert email is sent.

Now the problem is with this:

enter image description here

That prevents process from disappearing from process list, so we don’t get alert email about it’s failure. Is it possible to disable this message, that if program fails on something we don’t catch, it would close without user interaction?

  • 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-25T22:33:11+00:00Added an answer on May 25, 2026 at 10:33 pm

    Assuming Windows Forms, I typically do multiple steps to prevent this message box.

    First, I connect several handlers in the Main function:

    [STAThread]
    private static void Main()
    {
        Application.ThreadException +=
            application_ThreadException;
    
        Application.SetUnhandledExceptionMode(
            UnhandledExceptionMode.CatchException);
    
        AppDomain.CurrentDomain.UnhandledException +=
            currentDomain_UnhandledException;
    
        Application.Run(new MainForm());
    }
    

    Those handlers are being called when an otherwise unhandled exception occurs. I would define them something like:

    private static void application_ThreadException(
        object sender,
        ThreadExceptionEventArgs e)
    {
        doHandleException(e.Exception);
    }
    
    private static void currentDomain_UnhandledException(
        object sender,
        UnhandledExceptionEventArgs e)
    {
        doHandleException(e.ExceptionObject as Exception);
    }
    

    The actual doHandleException function that is then called does the actual error handling. Usually this is logging the error and notifying the user, giving him the options to continue the application or quit it.

    An example from a real-world application looks like:

    private static void doHandleException(
        Exception e)
    {
        try
        {
            Log.Instance.ErrorException(@"Exception.", e);
        }
        catch (Exception x)
        {
            Trace.WriteLine(string.Format(
                    @"Error during exception logging: '{0}'.", x.Message));
        }
    
        var form = Form.ActiveForm;
        if (form == null)
        {
            MessageBox.Show(buildMessage(e), 
                    "MyApp", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        else
        {
            MessageBox.Show(form, buildMessage(e), 
                    "MyApp", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
    

    With the helper function:

    public static string buildMessage(Exception exception)
    {
        var result = new StringBuilder();
    
        while (exception != null)
        {
            result.AppendLine(exception.Message);
            result.AppendLine();
            exception = exception.InnerException;
        }
    
        return result.ToString().Trim();
    }
    

    If you are using not Windows Forms but e.g. a Console application or WPF, some handlers are not present, while others are present instead.

    The idea stays the same: Subscribe to event handlers that are being called if you have no try...catch around your code blocks.

    Personally, I try to have as few of those try...catch blocks as possible (ideally none).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.