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. Closing applications gracefully

Closing applications gracefully

Scheduled Pinned Locked Moved C#
sysadmin
3 Posts 3 Posters 1 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi all I have a windows application that connects to a webservice. While the app is busy connecting to the webservice the network might be down, so the app kinda hangs while trying to connect to the webservice and I would like to be able to close the app but I'm unable cause the window doesn't respond to the mouse clicks. If there's any way to close the app gracefully, it would be nice. Thanks

    S 1 Reply Last reply
    0
    • L Lost User

      Hi all I have a windows application that connects to a webservice. While the app is busy connecting to the webservice the network might be down, so the app kinda hangs while trying to connect to the webservice and I would like to be able to close the app but I'm unable cause the window doesn't respond to the mouse clicks. If there's any way to close the app gracefully, it would be nice. Thanks

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      You'd need to use threads or asynchronous web service calls then. I'd prefer the latter. The code will look like

      public void CallWebService_ButtonClick(...)
      {
      new MethodInvoker(CallWebService).BeginInvoke(callback, ...);
      }

      private void CallWebService()
      {
      // Do the actual operation here
      }

      Just make sure that the UI updates you do from within CallWebService or from within the callback use Control.Invoke or Control.BeginInvoke[^]. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      D 1 Reply Last reply
      0
      • S S Senthil Kumar

        You'd need to use threads or asynchronous web service calls then. I'd prefer the latter. The code will look like

        public void CallWebService_ButtonClick(...)
        {
        new MethodInvoker(CallWebService).BeginInvoke(callback, ...);
        }

        private void CallWebService()
        {
        // Do the actual operation here
        }

        Just make sure that the UI updates you do from within CallWebService or from within the callback use Control.Invoke or Control.BeginInvoke[^]. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        D Offline
        D Offline
        Dylan van Heerden
        wrote on last edited by
        #3

        Thanks

        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