Note that there are some explanatory texts on larger screens.

plurals
  1. POProgressBar that updates as dictionary loads
    text
    copied!<p>Well I think I know the answer to this, but I would appreciate anybody confirming what I suspect.</p> <p>I have a large <code>dictionary</code> of zip codes that needs to load on program launch. It takes between 10-15 seconds, and I'd like to have a <code>progressbar</code> that could show, well, the progress. I can make the progress bar, and I have the total count specified as a setting. But from what I've been finding on other questions, it seems that <code>dictionary.count</code> cannot be bound to the progressbar with any hope of it updating regularly.</p> <p>Is this true? And if so, is there another way around it?</p> <p>Right now the dictionary is hardcoded, but I plan on changing that at some point in the future and have it load from a file instead. I know at that point I can just use a <code>foreach</code>loop to update the count each time around, but this seems kind of kludge-ish. Is there a better way to implement?</p> <p><strong>Edit:</strong></p> <p>As requested, code that loads the dictionary of zipCodes(there are actually about 40,000 more entries, but I thought I'd save space :p):</p> <pre><code>static class ZipCodes { #region Methods public static string GetValue(string key) { string result; if (zipCodeDictionary.TryGetValue(key, out result)) { return result; } else { return null; } } public static int GetCount() { return zipCodeDictionary.Count(); } #endregion #region ZipCode Dictionary Definition static Dictionary&lt;string, string&gt; zipCodeDictionary = new Dictionary&lt;string, string&gt;(); public static void PopulateZipCodeDictionary() { zipCodeDictionary.Add( "00501", "Holtsville, NY" ); zipCodeDictionary.Add( "00544", "Holtsville, NY" ); zipCodeDictionary.Add( "00601", "Adjuntas, PR" ); zipCodeDictionary.Add( "00602", "Aguada, PR" ); zipCodeDictionary.Add( "00603", "Aguadilla, PR" ); zipCodeDictionary.Add( "00604", "Aguadilla, PR" ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload