Why sending message to another app get failed after calling RApaLsSession::StartApp()?

Login to reply to this topic.
Mon, 2008-04-21 10:04
Joined: 2007-05-30
Forum posts: 9

                TApaTaskList taskList(CCoeEnv::Static()->WsSession());
                TApaTask task = (taskList.FindApp(aWebAppUid));
       
                if (!task.Exists())
                {
                        RApaLsSession session;
                        session.Connect();
                        TApaAppInfo aInfo;
                        TInt err = session.GetAppInfo(aInfo, aWebAppUid);
                        CApaCommandLine *commandline = CApaCommandLine::NewL();
       
                        CleanupStack::PushL(commandline);
       
        #ifdef EKA2
                        commandline->SetExecutableNameL(aInfo.iFullName);
        #else       
                        commandline->SetLibraryNameL(aInfo.iFullName);
        #endif       
       
                        commandline->SetDocumentNameL(relayUrl.DesC16());
                        commandline->SetCommandL(EApaCommandOpen);
                        ret = session.StartApp(*commandline);

After the last line, I called "task.SendMessage(msgUid, msgBody);" and get error code -1, and I checked task and found the window group id value is -1.
I got confused. What the hell has the "StartApp()" done? Why didn't my webApp start up at once? What should I do if I want to start a new application and send another message at once? That means I need get the result by call SetCommandL() first.


Wed, 2008-04-23 03:31
Joined: 2007-05-30
Forum posts: 9
Is there anybody could give

Is there anybody could give me an answer?

Wed, 2008-04-23 08:24
Joined: 2003-12-05
Forum posts: 672
Re: Why sending message to another app get failed after calling

Calling StartApp starts the application (I assume you have this checked), but of course this doesn't happen immediately. The launching takes time, you are in a multiprocessing enviroment so the turn to execute can be given also to other threads while your app and the app you launched is being started up. You just cannot assume that the application is there immediately ready to receive your messages.

If the other application is also yours, you could use a Semaphore to wait for the application to signal it is ready to roll. If this is not your app that you are launching, you could use a timer to wait for a reasonable amount of time and then try. If this fails, try again after a while.

Thu, 2008-04-24 06:04
Joined: 2007-05-30
Forum posts: 9
Thank you for your reply. I

Thank you for your reply. I have resolved this problem. As you said, I sent a message to another app with a timer calling back that in the other thread. But if I just wait after StartApp(), I will get failed no matter how long i would wait. I think that may be involved in something about thread switching. But I don't know what exactly happened.

  • Login to reply to this topic.