Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Event for handling exception during Application Close in winforms

Event for handling exception during Application Close in winforms

Scheduled Pinned Locked Moved C#
csharpdatabasewinformshelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rashmi_Karnam
    wrote on last edited by
    #1

    We have developed winform application in C#. Here when user logout we are storing logout time in database. Right now we have a code written in formclosing event for updating logout time. But if any error occurs while application is running / if we kill process from windows task manager then its not updating logout time. So please can any one suggest whats the best way to update logout time in Database. Because next time when user enters into application we are displaying message that "you are already logged in (System Name)system. Please logout!" . So if application is closed and logout time is not saved then user will get this message. So we want to update even if any exception in app / closed intentionally from task manager. Is there any event to handle this??? Please reply its very urgent..... :confused:

    Rashmi.M.K

    M V 2 Replies Last reply
    0
    • R Rashmi_Karnam

      We have developed winform application in C#. Here when user logout we are storing logout time in database. Right now we have a code written in formclosing event for updating logout time. But if any error occurs while application is running / if we kill process from windows task manager then its not updating logout time. So please can any one suggest whats the best way to update logout time in Database. Because next time when user enters into application we are displaying message that "you are already logged in (System Name)system. Please logout!" . So if application is closed and logout time is not saved then user will get this message. So we want to update even if any exception in app / closed intentionally from task manager. Is there any event to handle this??? Please reply its very urgent..... :confused:

      Rashmi.M.K

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      I don’t think that this (killing the application from Task Manager) can be handled with in the application itself. And in fact, there can be n number of scenarios like this: • What if I Shut Down my computer. • What if there is hard disk crash.

      1 Reply Last reply
      0
      • R Rashmi_Karnam

        We have developed winform application in C#. Here when user logout we are storing logout time in database. Right now we have a code written in formclosing event for updating logout time. But if any error occurs while application is running / if we kill process from windows task manager then its not updating logout time. So please can any one suggest whats the best way to update logout time in Database. Because next time when user enters into application we are displaying message that "you are already logged in (System Name)system. Please logout!" . So if application is closed and logout time is not saved then user will get this message. So we want to update even if any exception in app / closed intentionally from task manager. Is there any event to handle this??? Please reply its very urgent..... :confused:

        Rashmi.M.K

        V Offline
        V Offline
        vikas amin
        wrote on last edited by
        #3

        Solution 1. Create a timer thread, that will send message if you dont get message application is dead . 2. Trace the Process of the application , if you dont find the process the application is dead ( this has to be done from other process , so u have 2 process )

        Vikas Amin

        My First Article on CP" Virtual Serial Port "[^]

        modified on Thursday, July 24, 2008 5:33 PM

        R 1 Reply Last reply
        0
        • V vikas amin

          Solution 1. Create a timer thread, that will send message if you dont get message application is dead . 2. Trace the Process of the application , if you dont find the process the application is dead ( this has to be done from other process , so u have 2 process )

          Vikas Amin

          My First Article on CP" Virtual Serial Port "[^]

          modified on Thursday, July 24, 2008 5:33 PM

          R Offline
          R Offline
          Rashmi_Karnam
          wrote on last edited by
          #4

          thank u for good suggestion...

          Rashmi.M.K

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups