>>>>> ' Data dictionary >>>>> Public Tables As New Tables >>>>> Public TablesTemp As New Tables >>>>>>>>>>
>>>>> ' Load the data dictionary >>>>> Public Function LoadDataDictionary() As Boolean >>>>> >>>>> ' Make sure to clear all the tables. As when there is a flag to reload the >>>>> ' data dictionary, we need to make sure we reset the collection. >>>>> oApp.TablesTemp.Clear() >>>>> >>>>> ' Copy the TablesTemp into Tables >>>>> ' This allows a hit in progress to continue as is with this shared oApp object as we used a temporary place holder >>>>> ' during its initialization. Otherwise, a hit in progress may end up with an object reference not found. This was >>>>> ' happening before as it takes about 1.3 seconds to reload the data dictionary. >>>>> oApp.Tables = oApp.TablesTemp >>>>> >>>>> ' Let the framework know that we are done >>>>> ' This will only happen at startup as there is no need to turn this off on reload >>>>> App.lTables = True >>>>> >>>>> Return True >>>>> End Function >>>>>>>>>>
>>>> ' Data dictionary >>>> Public Tables As New Tables >>>> ' don't need this - Public TablesTemp >>>> >>>> ' Load the data dictionary >>>> Public Function LoadDataDictionary() As Boolean >>>> >>>> dim tablesTmp as new Tables >>>> >>>> 'the framework is still using Tables >>>> >>>> ' populate tablesTmp if needed >>>> >>>> oApp.Tables = tablesTmp ' from now on the newer version will be used >>>> >>>> ' Let the framework know that we are done >>>> ' This will only happen at startup as there is no need to turn this off on reload >>>> App.lTables = True >>>> >>>> Return True >>>> End Function >>>>>>
public string[] Tables = new string[] { "One", "Two", "Three" }; > > > public void UseTables() > { > foreach (string s in Tables) > { > //Do something > System.Threading.Thread.Sleep(1000); > } > } > > public void LoadDataDictionary() > { > string[] tables = new string[]{"One","Two"}; > Tables = tables; > } >If, for example, LoadDataDictionary() runs on one thread whilst UseTables() is running on another you've got problems...