surturz
Wed Jul 23 23:24:01 CDT 2008
I think the better solution is to restructure your program so that the user
can shut down whenever they want. Only start writing to disk (or whatever)
once all user input for the transaction is complete.
Generally a user can't click "X" unless you let them anyway. i.e. if you
have a loop running, the "X" event won't be handled until the loop closes.
As previously mentioned (by Cor I think) you can't stop a user pulling the
plug on the computer or killing the task in Taskman*. So it is better to give
the User a "Cancel" button to allow your long process to exit gracefully,
rather than to lock the UI, which only encourages them to kill the task or
reboot.
* Actually I think you CAN stop this, but you most certainly shouldn't.
--
David Streeter
Synchrotech Software
Sydney Australia
"rowe_newsgroups" wrote:
> On Jul 23, 3:18 am, "John" <i...@nospam.infovis.co.uk> wrote:
> > Hi
> >
> > My app does a few processes and the app can not be closes mid way. Therefore
> > I want to be able to block any attempt of closing app by user such as by
> > clicking on close (cross) or Alt-F4 and once the app is finished doing what
> > it is doing to close. In other words I need to close the app gracefully. How
> > can I achieve this?
> >
> > Thanks
> >
> > Regards
>
> I vote you let the user close the form, but you keep the processes
> running on a different thread that has IsBackground = False. That
> should (it's been a while since I've done it) let the form die
> immediately, but still keep the application alive and allow the
> processes to finish and then shut themselves down.
>
> Thanks,
>
> Seth Rowe [MVP]
>
http://sethrowe.blogspot.com/
>