public void Test1() { Unique.GetInstance(); taskCount = 0; set.Clear(); Task.Run(() => GetID()); Task.Run(() => GetID()); Task.Run(() => GetID()); Printf(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.RegisterAssembly("FytSoa.Application"); services.AddTransient(typeof(IBaseRepository <>), typeof(BaseRepository <>)); services.AddTransient(typeof(IBuilderTool), typeof(BuilderTool)); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); Unique.GetInstance(); services.AddCors(options => { options.AddPolicy(AllowSpecificOrigins, builder => builder.AllowAnyOrigin().AllowAnyHeader() .WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS") ); }); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "FytSoa API", Version = "v1" }); //Add Xml var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); //Add Bearer c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme() { Description = "在下框中输入请求头中需要添加Jwt授权Token:Bearer Token", Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.ApiKey, BearerFormat = "JWT", Scheme = "Bearer" }); }); }