I have following code:
void DownloadLists ()
{
if (!mIsListsDownl oaded)
{
// Loop -- Downloading entries for each list
foreach (ITritonList list in
TritonListManag er.GetLists(tru e))
{
list.OpenEntrie s(new
ListDataReadyDe legate(OnEntrie sDownloaded));
}
// Wrong in here, because the entries are not
downloaded at this time!!!
mIsListsDownloa ded = true;
}
}
void OnEntriesDownlo aded(IGridList list)
{
foreach (IGridEntry entry in list.Entries)
{
mEntries.Add(en try);
}
loggerCash.LogM essageBarMessag e(ESeverity.Det ail,
"Finished downloading entries on list " + list.Name.ToStr ing());
}
The task is to download entries on each list for multiple lists and
then set "mIsListsDownlo aded" to true. It's important that the action
"OnEntriesDownl oaded" be completed for all of the lists before
"mIsListsDownlo aded" is set to true.
I've found this a technical challenge -
The delegate method "OnEntriesDownl oaded" takes time to complete.
Also, since "OnEntriesDownl oaded" is called for each list and there
are multiple lists, it is called multiple times and it takes
significant amount of time (about 6 seconds, could take even longer
depending on how busy the system is) to complete.
Now the question is that when shall I set "mIsEntriesDown loaded" to
true? I want to wait for 8 seconds because by that time, all of the
entries should have been downloaded. However, there is no guarantee
because sometimes the system takes much longer.
I also don't know the C# syntax of waiting for 8 seconds and then set
"mIsListsDownlo aded" to true. Could anyone help?
Comment