Hi all,
I developed a simple program to store the click count in a database table. Multiple users click “Click” the same button simultaneously. Then Program counts the number of clicks and store in the database table. Specific user’s clicks can be seen by clicking view clicks button.
Problem
User A clicks “Click” button 10 times and user B clicks “Click” button 10 times simultaneously. At the end, click count value which was stored in database table, should be 20. But the actual value is less than 20. When we check the user clicks, by clicking “view Click” button, then the number of clicks are correct for when totaled for both users.
Click button code
function countClick()
{
var success=false;
if(foundset.find())
{
foundset.rec_no = 1;
foundset.search();
}
databaseManager.startTransaction();
while(!success){
success=databaseManager.acquireLock(foundset,-1);
}
if(success){
foundset.relookup();
foundset.click_count += 1;
clickCounter++;
arr+=‘,’+clickCounter;
if(databaseManager.saveData()){
databaseManager.commitTransaction();
}else{
databaseManager.rollbackTransaction();
}
databaseManager.releaseAllLocks();
}
}
View Click button code
function viewArray()
{
plugins.dialogs.showInfoDialog('Number of Clicks,'Array is : '+arr);
}
Please show me the correct way to get the click count in function countClick() in a multi-user environment.
Regards,
Sirikumara