Example #1
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            var asyncWorkoutServices = new AsyncWorkoutServices(token =>
            {
                Debug.WriteLine("Starting workout");

                var taskWorkout = new TaskWorkout(new Uri("http://localhost/"), token);

                var polling = new RunUpdatePolling<IEnumerable<string>>(taskWorkout.LoadAsync(), token, taskWorkout.ToString);

                return polling.RunAsync();
            }, new CryptographyService());

            GlobalServices.ServiceManager = asyncWorkoutServices;
            GlobalServices.Services = asyncWorkoutServices;
            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Url required");
                return;
            }

            try
            {
                if (ServicePointManager.DefaultConnectionLimit < 8)
                    ServicePointManager.DefaultConnectionLimit = 8;

                var asyncWorkoutServices = new AsyncWorkoutServices(token =>
                {
                    Debug.WriteLine("Starting workout");

                    var taskWorkout = new TaskWorkout(new Uri(args[0]), token);

                    var polling = new RunUpdatePolling<IEnumerable<string>>(taskWorkout.LoadAsync(), token, taskWorkout.ToString);

                    return polling.RunAsync();
                }, new CryptographyService());

                GlobalServices.ServiceManager = asyncWorkoutServices;
                GlobalServices.Services = asyncWorkoutServices;

                GlobalServices.ServiceManager.Launching();

                GlobalServices.ServiceManager.Initializer.Wait();

                var strings = GlobalServices.Services.Strings;

                GlobalServices.ServiceManager.Closing();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }