Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Duplicate Programs

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-26-2010, 04:45 AM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Default Duplicate Programs

Hi

I think this question has been asked before, but I cannot find the answer in the forum.

My question: how can I prevent a program from running twice on a PDA. There must be only one instance of a opened program on the PDA. If one has 2 copies of a program running on a PDA and one tries to access a Database, then the program comes up with an error message.

Thanks
Michael
Reply With Quote
  #2 (permalink)  
Old 01-26-2010, 10:16 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

In my experience Windows Mobile only allows a single copy of an application to run. If you try to run it again it focus goes to the existing instance.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #3 (permalink)  
Old 01-27-2010, 03:00 AM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Default

Hi Agraham

Thanks for the reply. But I have a problem.

I have had feedbacks from surveyors in the field that the program gives them a "Database Locked" error message.

Now when you go to "Settings", then "Memory" and then tap on "Running Programs" one will notice that the name "Ceaser" appears twice there.

I think what is happening is that they go into the program and use one of the routines that uses the Design Database. Then on some or other way, they start a second copy of the program and try to use the same Design Database again. As the first copy of the program has opened the database, the second program cannot access the database and therefore generates the error.

Please help.

Thanks
Michael
Reply With Quote
  #4 (permalink)  
Old 01-27-2010, 04:28 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Are they using a Windows Mobile device or Windows CE?
The single instance protection is a feature of Windows Mobile.

Maybe you can use the database to test whether another application is already running.
Try to access the database when you start your program and if it fails because it is locked then end the process.
Reply With Quote
  #5 (permalink)  
Old 01-27-2010, 04:37 AM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Default

Hi Erel

We are using the Workabout pro (Windows Mobile) from Psion.

Just a question. If I make a connection to a database (Con1.New) and I don't close it (Con1.Close) and I try to make a connection again, will a error be generated?

Thanks
Michael
Reply With Quote
  #6 (permalink)  
Old 01-27-2010, 08:26 AM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Default

Hi Erel\Agraham

I did a test now on my Recon (Windows Mobile) by tapping 3 times on the "Ceaser" icon and there were 3 copies of the program loaded!

Thanks
Michael
Reply With Quote
  #7 (permalink)  
Old 01-27-2010, 06:53 PM
linum's Avatar
Senior Member
 
Join Date: Sep 2008
Posts: 108
Default

Hello. I know my suggestion is not the best of the methods, and I do hope somebody else can post a concrete solution, but I have an app that at start up creates a CSV file named "ProgramON.csv" and when the program closes it renames that file to "ProgramOFF.csv". So you could possibly program a similar feature into your app and then add the following code to check if an instance of your program is already running as you start the program:

Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    
'Check to see if an instance of the program is already running    
    If FileExist(AppPath & "\ProgramON.csv"Then
        AppClose
    
End If
    
'Rename the ProgramOFF.csv to ProgramON.csv
    If FileExist(AppPath & "\ProgramOFF.csv"Then
        FileCopy(AppPath & 
"\ProgramOFF.csv", AppPath & "\ProgramON.csv")
        FileDel(AppPath & 
"\ProgramOFF.csv")
    
End If
    
    
'Your other code here
    
    Form1.Show
End Sub

Sub Form1_Close
    
    
'Rename the ProgramON.csv to ProgramOFF.csv
    If FileExist(AppPath & "\ProgramON.csv"Then
        FileCopy(AppPath & 
"\ProgramON.csv", AppPath & "\ProgramOFF.csv")
        FileDel(AppPath & 
"\ProgramON.csv")
    
End If
    
End Sub

Again, I hope there is a more elegant way of doing this but this is what I have been using and it works for me...
Reply With Quote
  #8 (permalink)  
Old 01-27-2010, 07:35 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Quote:
I did a test now on my Recon (Windows Mobile) by tapping 3 times on the "Ceaser" icon and there were 3 copies of the program loaded!
This is not the normal behavior of Windows Mobile.

@linum this solution is pretty problematic. If your program ends in some unexpected way (the user closed it with a task manager for example) the user will not be able to run it again.

You can use this library: http://www.basic4ppc.com/forum/addit....html#post2809 to see if a process is running.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate ghost form michaelm Questions (Windows Mobile) 9 08-23-2009 12:54 PM
How i can run my programs on smartphone? UnitZ Questions (Windows Mobile) 6 12-14-2008 03:42 PM
Can I do programs in background colin9876 Questions (Windows Mobile) 1 12-18-2007 07:33 AM
duplicate a form claveriel Questions (Windows Mobile) 5 11-19-2007 06:27 PM
Duplicate form and Copy control bidibulle Basic4ppc Wishlist 3 11-09-2007 06:39 PM


All times are GMT. The time now is 10:42 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0