Пример #1
0
        private void Populate()
        {
            cats     = Shiftorium.GetCategories();
            upgrades = new Dictionary <string, ShiftoriumUpgrade> [cats.Length];
            int numComplete = 0;

            avail = backend.GetAvailable();
            foreach (var it in cats.Select((catName, catId) => new { catName, catId }))
            {
                var upl = new Dictionary <string, ShiftoriumUpgrade>();
                upgrades[it.catId] = upl;
                var t = new Thread((tupobj) =>
                {
                    foreach (var upg in avail.Where(x => x.Category == it.catName))
                    {
                        upl.Add(Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP", upg);
                    }
                    if (it.catId == CategoryId)
                    {
                        this.Invoke(new Action(() =>
                        {
                            SetList();
                        }));
                    }
                    numComplete++;
                });
                t.Start();
            }
        }
Пример #2
0
        private void Populate()
        {
            cats     = Shiftorium.GetCategories();
            upgrades = new Dictionary <string, ShiftoriumUpgrade> [cats.Length];
            int numComplete = 0;

            avail = backend.GetAvailable();
            foreach (var it in cats.Select((catName, catId) => new { catName, catId }))
            {
                var upl = new Dictionary <string, ShiftoriumUpgrade>();
                upgrades[it.catId] = upl;
                var t = new Thread((tupobj) =>
                {
                    foreach (var upg in avail.Where(x => x.Category == it.catName))
                    {
                        upl.Add(Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP", upg);
                    }
                    numComplete++;
                });
                t.Start();
            }
            while (numComplete < cats.Length)
            {
            }                                     // wait for all threads to finish their job
        }