Posted on 2009-02-11
Last Modified: 2013-12-14
Hi Experts,

I have win app written in C# and it does everything fine except one.
When I catch SystemEvents.SessionEnding +=new SessionEndingEventHandler(SystemEvents_SessionEnding);

I cannot get rid of this .NET WindowsFormsParkingWindow. I tried everything but it still
pops up when user logs off.

Please help.

Here is major code.

Event :

SystemEvents.SessionEnding +=new SessionEndingEventHandler(SystemEvents_SessionEnding);

Function itself :

private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e) 




    // make delay to do calculations and then set to false

    e.Cancel = true;



      SessionEnd = true;

      e.Cancel = false;

      ExitWindowsEx(0, 0);




 // second time just exit app and system	







Open in new window

Question by:fpoyavo
    LVL 96

    Expert Comment

    by:Bob Learned
    One thought would be to do that in a different way.  Usually what I do is to detect the main form closing.
    LVL 1

    Accepted Solution

    Well, I tried it as well and same thing. I still see this crazy window. What I noticed is that it appears only when I do those Calculations. When I comment them out this window is gone. From my understanding this window in my case appears because session is ending and system trying to terminate my application but it still doing processing. This is true because when I press "End Now" button on this window my application does not complete calculations. My point here is that how we can control it ?
    I mean what can be done to somehow delay system logoff / end session before application completes
    its processing.

    LVL 96

    Assisted Solution

    by:Bob Learned
    What are you doing in these methods?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now