public TabularDataService(ISchedulerService schedulerService) { _schedulerService = schedulerService; using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { } }
protected override void OnStartup(StartupEventArgs args) { using (Duration.Measure(Logger, "OnStartup - " + GetType().Name)) { Logger.Info("Starting"); // ReSharper disable once RedundantToStringCallForValueType var dispatcherMessage = $"Dispatcher managed thread identifier = {Thread.CurrentThread.ManagedThreadId.ToString()}"; Logger.Info(dispatcherMessage); Debug.WriteLine(dispatcherMessage); Logger.Info($"WPF rendering capability (tier) = {(RenderCapability.Tier / 0x10000).ToString()}"); RenderCapability.TierChanged += (s, a) => Logger.Info($"WPF rendering capability (tier) = {(RenderCapability.Tier / 0x10000).ToString()}"); base.OnStartup(args); BootStrapper.Start(); var schedulerService = BootStrapper.Resolve <ISchedulerService>(); var messageService = BootStrapper.Resolve <IMessageService>(); var gestureService = BootStrapper.Resolve <IGestureService>(); ObservableExtensions.GestureService = gestureService; // Load the application settings asynchronously LoadSettingsAsync(schedulerService) .Wait(); var window = new MainWindow(messageService, schedulerService); // The window has to be created before the root visual - all to do with the idling service initialising correctly... window.DataContext = BootStrapper.RootVisual; window.Closed += HandleClosed; Current.Exit += HandleExit; // Let's go... window.Show(); if (Logger.IsInfoEnabled) { // Monitoring heartbeat only when info level is enabled... ObserveHeartbeat(schedulerService) .DisposeWith(_disposable); } #if DEBUG ObserveUiFreeze() .DisposeWith(_disposable); #endif ObserveCultureChanges() .DisposeWith(_disposable); Logger.Info("Started"); } }
public OverlayService() { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { _show = new Subject <OverlayViewModel>() .DisposeWith(this); } }
static CultureService() { using (Duration.Measure(Logger, "Constructor - " + typeof(CultureService).Name)) { Thread.CurrentThread.CurrentCulture = Cultures.First().Value; Thread.CurrentThread.CurrentUICulture = Cultures.First().Value; Changed = new BehaviorSubject <string>(Cultures.First().Key); } }
public HeartbeatService(TimeSpan interval, ISchedulerService schedulerService) { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { _listen = Observable.Interval(interval, schedulerService.TaskPool) .AsUnit() .Publish(); _listen.Connect() .DisposeWith(this); } }
public GesturesService() { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { _timer = new DispatcherTimer(TimeSpan.Zero, DispatcherPriority.ApplicationIdle, TimerCallback, Application.Current.Dispatcher); _timer.Stop(); } Disposable.Create(() => _timer.Stop()) .DisposeWith(this); }
public ColumnsService(ISettingsService settingsService) { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { _settingsService = settingsService; _initialised = new Subject <string>() .DisposeWith(this); _changed = new Subject <string>() .DisposeWith(this); } }
public IdleService(ISchedulerService schedulerService) { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { var mainWindow = Application.Current.MainWindow; if (mainWindow == null) { throw new Exception("Main window has not been created yet!"); } _idleObservable = Observable.FromEventPattern(h => mainWindow.Dispatcher.Hooks.DispatcherInactive += h, h => mainWindow.Dispatcher.Hooks.DispatcherInactive -= h, schedulerService.TaskPool) .Publish(); _idleObservable.Connect() .DisposeWith(this); } }
public DiagnosticsService(IIdleService idleService, ISchedulerService schedulerService) { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { _disposable = new CompositeDisposable() .DisposeWith(this); _sync = new object(); _countersObservable = CreatePerformanceCountersAsync() .DelaySubscription(Constants.UI.Diagnostics.DiagnosticsSubscriptionDelay, schedulerService.TaskPool) .SubscribeOn(schedulerService.TaskPool) .ObserveOn(schedulerService.TaskPool) .CombineLatest( idleService.Idling.Buffer(Constants.UI.Diagnostics.DiagnosticsIdleBuffer, schedulerService.TaskPool).Where(x => x.Any()), (x, y) => x) .Replay(1); } }
public SettingsService(ISchedulerService schedulerService) { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { _persist = new Subject <bool>() .DisposeWith(this); _persist.ObserveOn(schedulerService.TaskPool) .Synchronize(_persistSync) .Subscribe(_ => Persist()) .DisposeWith(this); _settings = new Dictionary <string, ISettings>(); var serializedSettings = Properties.Settings.Default.GlobalSettings; if (!string.IsNullOrEmpty(serializedSettings)) { JsonConvert.DeserializeObject <Dictionary <string, IEnumerable <Dtos.Setting> > >( serializedSettings, _serializerSettings) .ForEach(y => _settings.Add(y.Key, CreateSettings(y.Value))); } } }
public TabularDataService() { using (Duration.Measure(Logger, "Constructor - " + GetType().Name)) { } }
private static IObservable <Counters> CreatePerformanceCountersAsync() { return(Observable.Create <Counters>(x => { var disposable = new CompositeDisposable(); try { var processName = GetProcessInstanceName(); Logger.Info( "Creating performance counter 'Working Set'"); var workingSetCounter = new PerformanceCounter("Process", "Working Set", processName); disposable.Add(workingSetCounter); Logger.Info( "Creating performance counter '% Processor Time'"); var cpuCounter = new PerformanceCounter("Process", "% Processor Time", processName); disposable.Add(cpuCounter); using ( Duration.Measure(Logger, "Initialising performance counters (after creation)") ) { workingSetCounter.NextValue(); cpuCounter.NextValue(); } x.OnNext(new Counters(workingSetCounter, cpuCounter)); Logger.Info("Ready"); } catch (ArgumentException exn) { LogFailToCreatePerformanceCounter(x, exn); } catch (InvalidOperationException exn) { LogFailToCreatePerformanceCounter(x, exn); } catch (Win32Exception exn) { LogFailToCreatePerformanceCounter(x, exn); } catch (PlatformNotSupportedException exn) { LogFailToCreatePerformanceCounter(x, exn); } catch (UnauthorizedAccessException exn) { LogFailToCreatePerformanceCounter(x, exn); } return disposable; })); }