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
  1. Home
  2. General Programming
  3. C#
  4. Single instance over a local area network

Single instance over a local area network

Scheduled Pinned Locked Moved C#
sysadminperformancequestion
6 Posts 4 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.
  • M Offline
    M Offline
    Martin Hart Turner
    wrote on last edited by
    #1

    Hi: I am looking for a way to assure that only one instance of a WinForm application can be run on a local area network, how should I go about this? I'm not up to speed with Sockets or UDP communications, so don't really know where to start.

    --- Regards, Martin.

    A K 2 Replies Last reply
    0
    • M Martin Hart Turner

      Hi: I am looking for a way to assure that only one instance of a WinForm application can be run on a local area network, how should I go about this? I'm not up to speed with Sockets or UDP communications, so don't really know where to start.

      --- Regards, Martin.

      K Offline
      K Offline
      KaineDunno
      wrote on last edited by
      #2

      i think the easyest way is to create a dummy file somewhere on the network (accessable to everybody) when your app starts. and delete when app closes. in startup of your app, check for existens of that file (File.Exists) Hope this helps Kaine

      A 1 Reply Last reply
      0
      • M Martin Hart Turner

        Hi: I am looking for a way to assure that only one instance of a WinForm application can be run on a local area network, how should I go about this? I'm not up to speed with Sockets or UDP communications, so don't really know where to start.

        --- Regards, Martin.

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        Hmm. I found this topic: http://www.thescripts.com/forum/thread253568.html[^] Doesn't give much info, but from what i can see you can get remote processes by using: Process.GetProcesses("remote pc name"); and that you need to have remote access enabled on the rmeote machine, and maybe some other stuff. You might not need to use sockets at all, although they are rather quite simple to use. So, you'd have to check the processes of each machine individually, and then run your form if you don't find an instance of your form anywhere.

        My current favourite word is: Waffle Cheese is still good though.

        M 1 Reply Last reply
        0
        • K KaineDunno

          i think the easyest way is to create a dummy file somewhere on the network (accessable to everybody) when your app starts. and delete when app closes. in startup of your app, check for existens of that file (File.Exists) Hope this helps Kaine

          A Offline
          A Offline
          Anthony Mushrow
          wrote on last edited by
          #4

          Although of course, evil people could find an delete the file, then run the form when theyre not supposed to! :omg: Depends on your circumstances though. This is definitely a good idea though.

          My current favourite word is: Waffle Cheese is still good though.

          1 Reply Last reply
          0
          • A Anthony Mushrow

            Hmm. I found this topic: http://www.thescripts.com/forum/thread253568.html[^] Doesn't give much info, but from what i can see you can get remote processes by using: Process.GetProcesses("remote pc name"); and that you need to have remote access enabled on the rmeote machine, and maybe some other stuff. You might not need to use sockets at all, although they are rather quite simple to use. So, you'd have to check the processes of each machine individually, and then run your form if you don't find an instance of your form anywhere.

            My current favourite word is: Waffle Cheese is still good though.

            M Offline
            M Offline
            Martin Hart Turner
            wrote on last edited by
            #5

            Hmm, I was thinking more along the lines of a Broadcast or Multicast message and reply workaround. The created file solution might be a quick & dirty solution though...

            --- Regards, Martin.

            RaviBeeR 1 Reply Last reply
            0
            • M Martin Hart Turner

              Hmm, I was thinking more along the lines of a Broadcast or Multicast message and reply workaround. The created file solution might be a quick & dirty solution though...

              --- Regards, Martin.

              RaviBeeR Offline
              RaviBeeR Offline
              RaviBee
              wrote on last edited by
              #6

              MartinHart wrote:

              The created file solution

              Make sure you (a) create the file if it doesn't already exist and (b) keep it open for exclusive access as long as the app is running. /ravi

              This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

              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