Page 1 of 1

Long Middle Tier load time for a listBox

Posted: Mon Aug 09, 2021 6:00 pm
by wjstarck
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?

Re: Long Middle Tier load time for a listBox

Posted: Mon Aug 09, 2021 6:11 pm
by jordansparks
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.

Re: Long Middle Tier load time for a listBox

Posted: Mon Aug 09, 2021 7:34 pm
by wjstarck
OK, makes sense.

Made a few changes, and it really zips now.

Thanks.