Esempio n. 1
0
 private void Init()
 {
     lock (Filesloc)
         if (Files == null)
         {
             Memory.Log.WriteLine($"{nameof(Strings)} :: {nameof(Init)}");
             var tasks = new List <Task <bool> >();
             Files = new ConcurrentDictionary <FileID, StringsBase>();
             tasks.Add(Task.Run(() => Files.TryAdd(FileID.NAMEDIC, Namedic.Load()))); // areames and kernel require namedic
             //though there shouldn't be anything reading the strings till this is done processing
             //Task.WaitAll(tasks.ToArray());
             tasks.Add(Task.Run(() => Files.TryAdd(FileID.MNGRP, Mngrp.Load())));
             tasks.Add(Task.Run(() => Files.TryAdd(FileID.AREAMES, Areames.Load())));
             tasks.Add(Task.Run(() => Files.TryAdd(FileID.KERNEL, Kernel.Load())));
             Task.WaitAll(tasks.ToArray());
             if (tasks.Any(x => !x.Result))
             {
                 throw new ArgumentException($"{this}::Failed to add to dictionary...");
             }
         }
 }
Esempio n. 2
0
 private void Init()
 {
     lock (Lock)
         if (_files == null)
         {
             Memory.Log.WriteLine($"{nameof(Strings)} :: {nameof(Init)}");
             _files = new ConcurrentDictionary <FileID, StringsBase>();
             Func <bool>[] func =
             {
                 () => _files.TryAdd(FileID.Namedic,   Namedic.Load()), // area names and kernel require namedic
                 //though there shouldn't be anything reading the strings till this is done processing
                 //Task.WaitAll(tasks.ToArray());
                 () => _files.TryAdd(FileID.MenuGroup, MenuGroup.Load()),
                 () => _files.TryAdd(FileID.AreaNames, Areames.Load()),
                 () => _files.TryAdd(FileID.Kernel,    Kernel.Load()),
             };
             var tasks = Memory.ProcessFunctions(func);
             if (tasks.Any(x => !x))
             {
                 throw new ArgumentException($"{this}::Failed to add to dictionary...");
             }
         }
 }