示例#1
0
        public override bool OnStart()
        {
            try
            {
                // Set up the process defaults for connections to optimize storage performance
                ServicePointManager.DefaultConnectionLimit = int.MaxValue;

                var configuration = Configuration.GetCurrentConfiguration();

                _coordinator =
                    WarmStorageCoordinator.CreateAsync(RoleEnvironment.CurrentRoleInstance.Id, configuration).Result;

                return base.OnStart();
            }
            catch (AggregateException ae)
            {
                ae.Handle(ex =>
                {
                    Trace.TraceError(ex.ToString());

                    return false;
                });

                throw;
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());

                throw;
            }
        }
示例#2
0
        private static async Task RunAsync(CancellationToken token)
        {
            var configuration = Configuration.GetCurrentConfiguration();
            WarmStorageCoordinator processor = null;

            try
            {
                //TODO: using fixed names causes name collision when more than one instance is created within the processor host.
                //Consider changing to use Guid instead.
                processor = await WarmStorageCoordinator.CreateAsync("Console", configuration);

                Console.WriteLine("Running processor");

                await Task.Delay(Timeout.InfiniteTimeSpan, token);
            }
            catch (Exception) { }

            if (processor != null)
            {
                await processor.TearDownAsync();
            }
        }