application-shutdown

Prompt user to save when closing app

I'm writing what boils down to a document editor. When the application is closing, I need to prompt the user to save changes. This is easy enough. My question is when is it appropriate to not prompt the user, and instead simply discard unsaved data and close. In the FormClosing event, the CloseReason enum includes: None WindowsShutDow...

What is the correct way to add a Shutdown Hook for an Eclipse RCP application?

I have an RCP application that uses a connection to a in-memory database. There is one circumstance that, when shutting down windows, the application is killed without giving it a chance to close the connection to the database. I researched a little and it seems that adding a Shutdown hook is the best way to detect this event and do cl...

Shutting down a WPF application from App.xaml.cs

I am currently writing a WPF application which does command-line argument handling in App.xaml.cs (which is necessary because the Startup event seems to be the recommended way of getting at those arguments). Based on the arguments I want to exit the program at that point already which, as far as I know, should be done in WPF with Applica...

Is there a C++ function to turn off the computer?

Is there a C++ function to turn off the computer? And since I doubt there is one (in the standard library, at least), what's the windows function that I can call from C++? Basically, what is the code to turn off a windows xp computer in c++? ...

If unhandled exception happens I need to shutdown the WPF Application?

I have a WPF Application basically the exe is a loader for the application UI and sometimes when a unhandled execption occurs the message box is shown and when I click ok it goes away,the UI vanishes etc..,the instance of the exe is still there,I need some mechanism that when and exception that is unhandled occurs shutdown the exe since ...

Determine exit status within the java shutdown hook thread

Hi, I would like to determine the exit status of the process during the shutdown hook runtime. I want to have a logic which is based on the status code (0 or nonzero) (ex: if zero do nothing else nonzero send an alert email) Do you know how I can get this information? ...

How to turn off pc via windows API?

Hello all I never programmed a winapi so i have a little problem here . I need turn off my pc from my application . I found this example link text then i found this example how to change privileges link text But i have problem how to get that parameter HANDLE hToken // access token handle I think i need to make it in the next orde...

Can a shutdown hook rely on another thread?

In a shutdown hook method, I need it to send a message to another process to say it has shutdown. My current message handling code requires that the message be written into a queue, this queue is processed by another thread and sent on to wherever it is going. In this case, to be written into a pipe file by another thread. In a shutdown...

jna call to kernel32.CreateToolhelp32Snapshot in shutdown hook crashes the VM

If a thread sets a shutdown hook using Runtime.getRuntime().addShutdownHook(); calls via jna the method: kernel32.CreateToolhelp32Snapshot (0x00000002, 0) it crashes the VM. If I call the same method in the WindowListener.windowClosing() hook, the call does not crashes the VM. Any idea why? I can post part of the VM crash e...

How to properly quit application, call exit(0) ?

I'm not sure which is the right way, right now I'm just calling exit(0) when a user clicks on the exit button. ...

Shutdown exception handling for Win32/C++

I have a process that handles exceptions great. It calls: _set_se_translator(exception_trans_func); SetUnhandledExceptionFilter(UnhandledExceptionFilterHandler); _set_purecall_handler(purecallHandler); set_terminate(terminateHandler); set_unexpected(unexpectedHandler); _set_invalid_parameter_handler(InvalidParameterHandler); atexit(ex...

How to call event before Environment.Exit() ?

I have a console application. If something goes wrong i need to call Environment.Exit(); to close my app. I need to disconnect and close some files before my application exit. In Java i can implement Runtime.getRuntime().addShutdownHook(). Can someone help me? ...

Application.Current.Shutdown() doesn't

Title's about it. WPF app with some WCF stuff for IPC. I call Application.Current.Shutdown() and the app continues on happily. I thought Shutdown was supposed to be unstoppable. Perhaps because it's being called from a background thread? Do I need to do some dispatcher fiddling? ...

How to interrupt Eclipse RCP shutdown

I have a plugin into an eclipse rcp application. I need to detect a scenario whenever a particular perspective is closed or if the application is closed and based on the outcome, I may need to cancel the closing of the app or perspective. If I had access to the application's WorkbenchAdvisor class, this would be trivial. As a plugin t...

Diagnosing IIS Shutdowns

Symptoms: I attach a debugger, I wait a little while, it automatically detaches I watch the event log during normal operation - after a single request comes in, it waits a little bit, the shuts down Disagnosing. I've followed the following steps for logging shutdowns in IIS: http://weblogs.asp.net/scottgu/archive/2005/12/14/433194....

What does WIX's CloseApplication functionality do and how would can the application respond to such a signal

In the WIX setup I've got, when upgrading the application I have set a requirement to close down applications which might hold on to files which needs to be updated: <util:CloseApplication Id="CloseMyApp" Target="[MyAppExe]" CloseMessage="yes" Description="!(loc.MyAppStillRunning)" RebootPrompt="no" ElevatedClos...

applicationShouldTerminate: and cleanup during app termination

I'm looking are some CrashReporter logs for my Cocoa/MacOSX application and it looks like the reason for the crash is that some cleanup I expect to perform in the [applicationShouldTerminate:] method of the NSApplicationDelete isn't being performed. However, the app is terminating as evidenced by the following trace: 1 libSystem.B.dyl...