Make console program unload faster
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Make console program unload faster

  1. #1
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    447

    Question Make console program unload faster

    I have a very simple console program that looks up something in the database, and if it finds something, shows it in a messagebox.

    The lookup is fast, but the time from I click "Ok" in the messagebox to the program exits is too long (1-2 secs). Can I speed that up somehow?

    All the DB stuff is done (connection closed and all). I assume it is the garbage collector or something? How to terminate the program faster?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,197

    Re: Make console program unload faster

    Probably showing it in a messagebox causes the framework to add a messagepump to the console window (which needs to be torn down while closing the console window).

    As a test, try displaying the results to the console windows instead of using the MessageBox.

  3. #3
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    447

    Re: Make console program unload faster

    I tried something else. I tried to use just the messagebox, and disable all my DB access. Then it closed really fast.

    But my db connection is closed and disposed before I ever show the message box...

    I've started using
    Process.GetCurrentProcess().Kill();
    when I end the program, and that works like a charm...but I'm just afraid, that this will result in some other, currently unknown, problems...

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,197

    Re: Make console program unload faster

    Try hiding the console window before you exit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center