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. Run Once and accept parameters

Run Once and accept parameters

Scheduled Pinned Locked Moved C#
2 Posts 2 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.
  • C Offline
    C Offline
    Christopher Thornburg
    wrote on last edited by
    #1

    I am working on a POS application that needs to run once, and then when called again it will just activate the current instance. So I have the run once code working but now I need to be able to pass params to the running instance. I am trying to implement a way to save the params to my properties.settings.default.param1, so when the exe is called the second time, I check for an existing instance by name, and if I find it I restore it. before I restore it I save the value of my params, and in the activated event of my form, I grab that data and present it to the user. Well this is not working all the time, sometimes it works sometimes it does not...I'm totally open to new ideas on this process... :doh:

    Christopher J. Thornburg Senior Systems Analyst Ideal Card

    L 1 Reply Last reply
    0
    • C Christopher Thornburg

      I am working on a POS application that needs to run once, and then when called again it will just activate the current instance. So I have the run once code working but now I need to be able to pass params to the running instance. I am trying to implement a way to save the params to my properties.settings.default.param1, so when the exe is called the second time, I check for an existing instance by name, and if I find it I restore it. before I restore it I save the value of my params, and in the activated event of my form, I grab that data and present it to the user. Well this is not working all the time, sometimes it works sometimes it does not...I'm totally open to new ideas on this process... :doh:

      Christopher J. Thornburg Senior Systems Analyst Ideal Card

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I dont know enough about settings files, I am not sure how it would behave when more than one app instance exists, and how you could use them to communicate (the first instance needs to reread once the second one changes the settings?). Also I want solutions that would work on older .NET versions (1.1) I have an app that wants to run as a singleton. My implementation works fine on .NET 1.1 and 2.0 If it can create a named mutex, it knows it is the first instance, and it creates a named pipe (sounds like the mutex is not really needed, could just try and create the pipe right away I guess). Otherwise, it connects to the pipe, sends the command line thru it, and exits. The first instance has a separate thread that reads on the pipe, and acts on it when something is received. I use PInvoke to call CreateFile, WriteFile, ReadFile, CreateNamedPipe, ConnectNamedPipe and CloseHandle. :)

      Luc Pattyn [My Articles]

      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