static void Main(string[] args) { var endpoint = new LocalEndpoint(); endpoint.Start(); var bus = Settings.RootContainer.GetInstance<IInMemoryBus>(); var stopwatch = new Stopwatch(); stopwatch.Start(); Parallel.ForEach(Iterations, i => { bus.Execute(new AddRecordToDatabase(i + 1)); }); stopwatch.Stop(); Console.WriteLine(TimeSpan.FromTicks(stopwatch.ElapsedTicks)); Console.ReadKey(); }
private static void ConfigureWebApi(IAppBuilder app, HttpConfiguration config) { config.Formatters.Remove(config.Formatters.XmlFormatter); config.MapHttpAttributeRoutes(); var corsAttr = new EnableCorsAttribute("*", "*", "*"); config.EnableCors(corsAttr); config.Routes.MapHttpRoute( name: RouteNames.DefaultApi, routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); app.UseCors(CorsOptions.AllowAll); app.UseWebApi(config); var endpoint = new LocalEndpoint(); endpoint.Start(); config.DependencyResolver = ((WebApiAutofacAdapter)Settings.RootContainer).BuildAutofacDependencyResolver(); GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; }
static void Main(string[] args) { var endpoint = new LocalEndpoint(); endpoint.Start(); var bus = Settings.RootContainer.GetInstance<IInMemoryBus>(); var stopwatch = new Stopwatch(); stopwatch.Start(); foreach (var i in Iterations) { try { bus.Execute(new AddRecordToDatabase(i + 1)); } catch (Exception) { } } //Parallel.ForEach(Iterations, i => //{ // try // { // bus.Execute(new AddRecordToDatabase(i + 1)); // } // catch (Exception ex) // { // Console.WriteLine(ex.Message); // } //}); stopwatch.Stop(); Console.WriteLine(TimeSpan.FromTicks(stopwatch.ElapsedTicks)); Console.ReadKey(); }