Sunday, March 1, 2009

How to run windows mobile application as a background process?

To send your application to the background, you can use Hide() function.

For example, when you have a form (myForm) to hide, call this, myForm.Hide(). This results in that myForm.visible is set with "false".

To check that your application is really running on background, let's go to the "Settings -> System tab -> Memory -> Running programs tab".

Unfortunately, you cannot find your application on the list. (But, actually your application is running as a backroung process.)

Now, let's check with "Remote Process Viewer". Click "Microsoft Visual Studio 2005 -> Visual Studio Remote Tools -> Remote Process Viewer". (You need to connect your mobile device to your computer.)

You can surely find your application's name on the Process list. To kill it, click "X" icon on toolbar menu.

This is a drawback when you use Hide() function to send your application to the background.

Here is another way to overcome this problem.

It is to use the Native function "ShowWindow()" with the ‘Minimized’ property:

static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_MINIMIZE = 6;
public void Hide()
ShowWindow(myForm.Handle, SW_MINIMIZE);


1 comment:

html5 audio player said...

I have no words for this great post such a awe-some information i got gathered. Thanks to Author.
html5 audio player