Application interaction with another application/service/Backgroundthread

P

prathibhas

I have a project which is a device application (Windows Mobile 6 -
Smartphone). In this application i will download some xml(catalog)
files from the sever and update the ui and database once in 24hrs.
This download,updation of ui and updation of database(sql server ce)
takes nearly 3 to 4 mins.

To avoid this i want to create service/thread or something else which
will be running in the background and do this download process and
update the database without poping up the ui. So that when user opens
my application he has to just update the ui reading from database.

Can anyone please suggest me what i have to use for this
functionality?
1)Do i need to create 2 different applicatios and has to communicate
between those 2 applications.If so how can i communicate between 2
different applications.
2)Do i need to create one service and have to communicate to my
application. If i use a service can i get object of different
application.
3)Is there any event trigger application in WM6 so that i can get
events and use them.

please suggest me.

Note: Iam using VS2005,WM6(Compact framework and SQL server ce)
platform.

thanking you.

Regards,
Prathibha
 
P

Paul G. Tobey [eMVP]

1. No, you don't *have* to have separate applications. You could do the
update in a thread of the main application. You could use multiple
applications. It's entirely up to you. You might use a point-to-point
message queue for communication (if you need to pass data from one to the
other), or you might simply set a named event object (OS-level object), and
check that in the other application, or you might broadcast a window message
which the other application would listen for. If all you need to do is
signal, hey, there's a new version of the database; close the one you have,
copy this one over the top and start using it, I'd use a named event.

2. No, of course you can't access the objects in another program from a
second one, whether it's a service or not. That doesn't mean that you can't
communicate with another program. You can't simply call xyz.Invoke( ... ),
though.

3. Events like what? Sorry, but this question seems to come from no where.
As mentioned above, you can use an "event", in the operating system sense,
to trigger some action from an interested application. The other
application will probably have to have a thread to listen for the event and
then take action to notify the main UI thread that it's time to do
something. Or do you mean something else by "event"?

Paul T.
 
P

prathibhas

Hi Paul,
Thanks for your valuable suggestions.(Sorry for late reply).

1.You have mentioned that i could do the update in a thread of the
main application, if i close my main application, even the thread will
be stopped. I want some thread which should be running always..when
the mobile is switched on...whether my main application is opened or
not.Based on some time constraint, background thread( i dont know
proper name for that thread)should download the catalog and update the
database.
I tried creating 2 simple applications and used point-to-point
message queue for communication, i was able to pass a simple string
from one application to the other application.

2.Ok, i cant use a service.

3. I meant samething by the word event.You have mentioned that i can
use an "event", in the operating system sense...can u please explain
me little more on this.

4.I want to decide whether i have to use multiple applications or a
single application. Can u please tell is there any thread(something)
which will be running always when the mobile is switched on.So that i
can communicate with my main application.

Thanking you,
Prathibha
 
P

Paul G. Tobey [eMVP]

Hi Paul,
Thanks for your valuable suggestions.(Sorry for late reply).

1.You have mentioned that i could do the update in a thread of the
main application, if i close my main application, even the thread will
be stopped. I want some thread which should be running always..when
the mobile is switched on...whether my main application is opened or
not.Based on some time constraint, background thread( i dont know
proper name for that thread)should download the catalog and update the
database.
I tried creating 2 simple applications and used point-to-point
message queue for communication, i was able to pass a simple string
from one application to the other application.

Great, so you're set.
3. I meant samething by the word event.You have mentioned that i can
use an "event", in the operating system sense...can u please explain
me little more on this.

An operating system event is a particular type of object that has a
well-defined set of semantics associated with it. You can read the help to
find out what those are. The help for CreateEvent() in the native code SDK
is probably the starting point.
4.I want to decide whether i have to use multiple applications or a
single application. Can u please tell is there any thread(something)
which will be running always when the mobile is switched on.So that i
can communicate with my main application.

No, absolutely not. However, a program doesn't have to "pop up", any more
than a service has to have a UI. I don't, I guess, understand what the
problem is. You have a process that will last four minutes, during which a
database will be inaccessible, but, during that process, the database has to
be accessible?! That sounds like what you're saying and it's clearly
contradictory. I personally don't see *any* reason not to have a single
application that uses a separate thread to periodically download and do
whatever needs to be done to the database. Unless you need precise timing
of when that happens, you could just have the main thread set a timer and,
roughly every 24 hours start the download thread. Yes, if someone exits the
application, it will be exited. So, what do you do about that? You don't
allow it to be exited, of course.

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top