Long Middle Tier load time for a listBox

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Long Middle Tier load time for a listBox

Post by wjstarck » Mon Aug 09, 2021 6:00 pm

Hello-

I have a form that is taking a long time to fill a ListBox on Middle Tier.

Here is the ListBox code:

Code: Select all

		public void FormAnesthProvLocations_Load(object sender, System.EventArgs e) {
            List<Provider> listShort = new List<Provider>();
            listShort = Providers.GetDeepCopy(true);
            this.listProv.Items.Clear();
			for(int i=0;i<listShort.Count;i++) {
				this.listProv.Items.Add(Lan.g(this,listShort[i].GetLongDesc()));
			}
            this.listLocation.Items.Clear();
			DataTable table = AnesthLocations.RefreshCache();
			locationCur = new AnesthLocation();
			for(int i=0;i<table.Rows.Count;i++) {
                locationCur.LocationNum = PIn.Long(table.Rows[i][0].ToString());
                locationCur.LocationName = PIn.String(table.Rows[i][1].ToString());
                listLocation.Items.Add(locationCur.LocationName);
			}
            string bob = String.Empty;
            this.listProv.SelectedIndex = 0;
			
		}
and here is the RefreshCache method:

Code: Select all

		public static DataTable RefreshCache() {
			//No need to check RemotingRole; Calls GetTableRemotelyIfNeeded().
			string command="SELECT * FROM anesthlocation ORDER BY LocationName";
			DataTable table=Cache.GetTableRemotelyIfNeeded(MethodBase.GetCurrentMethod(),command);
			table.TableName="AnesthLocation";
			FillCache(table);
			return table;
		}
Any way I can speed this up?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
jordansparks
Site Admin
Posts: 5739
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Long Middle Tier load time for a listBox

Post by jordansparks » Mon Aug 09, 2021 6:11 pm

You wouldn't normally call RefreshCache. That's only used if you changed the cache, maybe by adding a new item. The whole point of a cache is to be able to not go back to the database each time. We use lazy loading of cache tables. Each table starts out null. If you ever need a table and it's null, then it calls RefreshCache, but after that it does not.
Jordan Sparks, DMD
http://www.opendental.com

User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Long Middle Tier load time for a listBox

Post by wjstarck » Mon Aug 09, 2021 7:34 pm

OK, makes sense.

Made a few changes, and it really zips now.

Thanks.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

Post Reply