locked
Reactivate running mobile app with arguments RRS feed

  • Question

  • Hi ,

    I have made a application which on installation(using setup CAB proj) installs two short cuts. One in "programs folder " and other in " start menu". The start menu  shortcut has a command argument as i want a specific part of app to run when application started from startmenu and when started from "Programs folder" i want the app to run in normal mode. Now, both my requirments are working fine as long as application is not already running. If app is already running(in background), and i start it from "start menu", the arguments are not being processed. Here is the code i have written to process the command arguments.

    static

    void Main(String[] args)
    {
    if (args != null && args.Length > 0)
    {
    if (args[0] == "something")
    {
    //do something specific
    }
    else
    {
    //run the normal mode(default form1).
    }

    ----
    so what i want to know is if this Main () method called when the application is already running in background and its reactivated using the short cut in "start menu". If not then while reactivating, which events are fired, and which one i can use to process the command arguments? I have checked that Activated and OnFocus events don't give the command arguments.
    Please suggest some solution. Thanx.
    Sunit.

    Monday, October 26, 2009 12:49 PM

Answers

  • You have to set up some form of IPC mechanism to send the new arguments to the existing app (and shut off the CF's half-baked attempt at keeping an app singleton).  Typically I use a worker thread to listen for the activation and arguments and a Point to point queue to transmit them.
    • Marked as answer by warrentang Friday, October 30, 2009 2:53 AM
    Monday, October 26, 2009 2:08 PM

All replies

  • You have to set up some form of IPC mechanism to send the new arguments to the existing app (and shut off the CF's half-baked attempt at keeping an app singleton).  Typically I use a worker thread to listen for the activation and arguments and a Point to point queue to transmit them.
    • Marked as answer by warrentang Friday, October 30, 2009 2:53 AM
    Monday, October 26, 2009 2:08 PM
  • Thanx for the reply.  Can you illustrate how the worker process can get and process the arguments that I want to process?
    Tuesday, October 27, 2009 6:38 AM