Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

WindowsFormsParkingWindow

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) 
{ 
if(!SessionEnd)
{
    // make delay to do calculations and then set to false
    e.Cancel = true;
    CalculateDays(); 					
     CalculateTimet();
      SessionEnd = true;
      e.Cancel = false;
      ExitWindowsEx(0, 0);
}
else
{
 // second time just exit app and system	
 my.Form1.ActiveForm.Dispose();
this.Dispose();					
Application.ExitThread();
Application.Exit();
 
}
 
 
Thanks.

Open in new window

0
fpoyavo
Asked:
fpoyavo
  • 2
2 Solutions
 
Bob LearnedCommented:
One thought would be to do that in a different way.  Usually what I do is to detect the main form closing.
0
 
fpoyavoAuthor Commented:
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.

Thanks.
0
 
Bob LearnedCommented:
What are you doing in these methods?

      CalculateDays();                                    
      CalculateTimet();
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now