Any way to inform the (windows)UI, that validation is undergoing?

Any way to inform the (windows)UI, that validation is undergoing?

Old forum URL: forums.lhotka.net/forums/t/8609.aspx


vschaak posted on Wednesday, March 03, 2010

Hi,

let me first express my gratefulnes to all of you guys that are involved in developing CSLA! Once some key concepts (like the child-handling for example) are understood, it makes perfect sense and all seems to be on the right place.

Now to my question: my object (editable root/base) has one property that should be unique. It's not the ID or primary key in the DB, but has a unique index there. Now I added a supporting commandBase class, that check's whether this value is unique against the DB. This is called during the validation and works just fine. But how do I inform the UI to show some busy-stuff while processing validating to the users? Actually DB response is quite fast since it returns only a single value, but realtime DB-access tends to slow down things as we know...

Thx for any help

Volker

ajj3085 replied on Wednesday, March 03, 2010

Is this Wpf, or WinForms?

vschaak replied on Wednesday, March 03, 2010

Hi Andy,

it's a WinForms App.

Greetings

Volker

JonnyBee replied on Wednesday, March 03, 2010

Hi,

Wouldn't it be better to run that validation rule (or database llokup) asyncronously and just show an error icon if the rule is broken?

If the rule/command object is running in the UI thread you will not be able to show a reasonable "busy" stuff -  the rule or command object must be running on a separate thread to keep the UI responsive.

And also use MarkBusy and MarkIdle (will call OnBusyChanged event  that the UI can listen to) and will "lock" the object while validation is running.

 

 

rsbaker0 replied on Wednesday, March 03, 2010

We do database-level validation for all foreign keys via business rules through out our application. When an object is bound to the UI, the database hits typically only one field at a time, when the user tabs out of the field. I haven't noticed it being a problem yet.  If you are querying a unique key or unique value in an index, the database should respond very quickly, typically in a fraction of a second unless there are locking issues (and in fact round-trip to the server can be almost as long if this is going over a WAN).  

If it is a concern, in WinForms you could hook the Validating and Validated Events for the control in question and change the cursor to a wait cursor in the former and restore it in the latter.

RockfordLhotka replied on Wednesday, March 03, 2010

We actually created a busy animation control for Windows Forms, with the intent that you could use the object's IsBusy property to turn it on and off. Since you can't bind as flexibly in Windows Forms as in Xaml you'll need to hook the PropertyChanged and ValidationComplete events off the object to see when IsBusy is set one way or the other, but it should be pretty practical.

vschaak replied on Monday, March 08, 2010

Hi all,

thank's very much! I'll give it a try. Thereby I'll have to take care, that changing the busy state doesnt have more impact as DB latency itself, since I experienced really fast DB-response even across WANWink

Thank's again and have a good time!

Volker

Copyright (c) Marimer LLC