Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pessimistic buffering problem!
Message
From
02/10/1998 14:02:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/10/1998 14:00:37
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00142782
Message ID:
00143369
Views:
27
>>Just my opinion. Do not use "automatic". Have a timer, if rlock() unsuccesfull, display message and enable timer. Timer is there for checking if it can place a lock + displaying still in use while the user is waiting. If s/he navigates to another rec disable timer. Works good with pessimistic.
>>Cetin
>
>Thanks for responding. Could you expand on when you would test for rlock() in the form and how the user would be able to navigate away from the record while a message is dislaying.
>
>- Edward
Hi Edward,
A very simple code for edit/revert and timer here to demonstrate. Simple because many checks are dropped, all controls are base textbox or commandbutton. Just enough to show messaging :
* Form.init - Has custom prop editmode
this.comment = this.caption && Save caption

* Edit.click
if !thisform.editmode
  if rlock()  && Try explicit lock
              && Because pessimistic locking only does it if editing starts
              && User might be confused if s/he could get into editmode
              && Head turns to phone then back, presses a key to start edit
              && But another speedy has already locked implicitly
    thisform.editmode = .t.
    thisform.setall("Enabled",.t.)
  else
    wait window nowait "Record in use..."
  endif
else
  tableupdate()
  unlock
  thisform.editmode = .f.
endif
thisform.setall("Enabled",thisform.editmode,"TextBox")
thisform.setall("Enabled",.t.,"Commandbutton")
thisform.Command3.caption = iif(thisform.editmode,"Revert","Add")
this.caption = iif(thisform.editmode,"Save","Edit")

* Add.click  - add code completely dropped and simplified
if thisform.editmode
  tablerevert()
  unlock
endif
thisform.editmode = !thisform.editmode
thisform.setall("Enabled",thisform.editmode,"TextBox")
thisform.setall("Enabled",.t.,"Commandbutton")
this.caption = iif(thisform.editmode,"Revert","Add")
thisform.Command1.caption = iif(thisform.editmode,"Save","Edit")

* Timer.timer
if !thisform.editmode
  thisform.refresh
  * Notification part
  if !rlock()
    thisform.caption = thisform.comment + "..Someone is editing.."+time()
  else
    thisform.caption = thisform.comment + "..Record available.."+time()
  endif
  unlock
endif
User would be able to navigate because you would use form.caption, status bar, wait window etc but not a messagebox. And of course you should support timer messaging with other code in navigation (ie: "someone is editing" displays, user moves on to another rec, might wrongly continue to see message "someone is editing" till timer fires again).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform