コード例 #1
0
        public static IServiceCollection AddIdGen(this IServiceCollection services, IConfiguration configuration)
        {
            IdGenSettings settings = new IdGenSettings();

            configuration.Bind(settings);

            IdGenDistributedId.Initialize(settings);
            return(services);
        }
コード例 #2
0
        public static IServiceCollection AddIdGen(this IServiceCollection services, Action <IdGenSettings> action)
        {
            IdGenSettings settings = new IdGenSettings();

            action(settings);

            IdGenDistributedId.Initialize(settings);
            return(services);
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: yzbai/HB.FullStack
        public async Task Test1Async()
        {
            IdGenDistributedId.Initialize(new Microsoft.Extensions.DependencyInjection.IdGenSettings { MachineId = 0 });
            ConcurrentDictionary<long, int> dict = new ConcurrentDictionary<long, int>();

            List<Task> tasks = new List<Task>();

            for (int i = 0; i < 100; ++i)
            {
                tasks.Add(GenerateIdAsync(dict));
            }

            await Task.WhenAll(tasks).ConfigureAwait(false);

            var ordered = dict.OrderBy(kv => kv.Key);
        }