Beispiel #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Database.SetInitializer(new MigrationInitializer());

            WebSocketBlockStream stream = new WebSocketBlockStream(new Uri(ConfigurationManager.AppSettings["endPoint"]));

            if (stream != null)
            {
                runningTasks.Add(stream.ProcessRequest(HttpContext.Current));
            }

            CancellationTokenSource tokenSource = new CancellationTokenSource();
            DateTime startTime = RoundCurrentToNextFiveMinutes();

            Task timerTask = RunPeriodically(
                startTime, TimeSpan.FromMinutes(10), tokenSource.Token);

            runningTasks.Add(builder.CompleteBlockAdding(CancellationToken.None));

            Task.WaitAll(runningTasks.ToArray(), tokenSource.Token);
        }