public MainWindow() { InitializeComponent(); CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name); ci.DateTimeFormat.ShortDatePattern = "dd.MM.yyyy"; Thread.CurrentThread.CurrentCulture = ci; CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal; CurrentCompanyId = customPrincipal.Identity.CompanyId; CurrentCompany = new CompanyViewModel() { Id = customPrincipal.Identity.CompanyId, Identifier = customPrincipal.Identity.CompanyIdentifier, CompanyName = customPrincipal.Identity.CompanyName }; CurrentUserId = customPrincipal.Identity.Id; CurrentUser = new UserViewModel() { Id = customPrincipal.Identity.Id, Identifier = customPrincipal.Identity.UserIdentifier, FirstName = customPrincipal.Identity.Name, LastName = customPrincipal.Identity.LastName }; // First page to display is Home page cntCtrl.Content = new Home(); LoadConfiguration(); //OpenTab("Početna", new Home()); this.Closing += MainWindow_Closing; Thread td = new Thread(() => { hubConnection = new HubConnectionBuilder() .WithUrl(WpfApiHandler.GetPublicUrl() + "/notifications") .Build(); hubConnection.KeepAliveInterval = TimeSpan.FromSeconds(15); hubConnection.On <CallCentarViewModel>("SendMessage", (msg) => { Application.Current.Dispatcher.BeginInvoke((System.Action)(() => { CallCenterNotification_Popup popup = new CallCenterNotification_Popup(msg); popup.WindowStartupLocation = WindowStartupLocation.CenterScreen; popup.Owner = this; popup.ShowDialog(); })); }); hubConnection.On <ToDoViewModel>("SendToDo", (msg) => { Application.Current.Dispatcher.BeginInvoke((System.Action)(() => { //MainWindow.WarningMessage = $"TO-DO:\n{msg.Name}\n{msg.Description}"; ToDoNotification_Popup popup = new ToDoNotification_Popup(msg); popup.WindowStartupLocation = WindowStartupLocation.CenterScreen; popup.Owner = this; popup.ShowDialog(); })); }); hubConnection.Closed += HubConnection_Closed; hubConnection.ServerTimeout = TimeSpan.FromHours(1); hubConnection.On <CallCentarViewModel>("GroupMessage", (msg) => { }); hubConnection.On <string>("AcceptedToNotificationChannel", (msg) => { //Console.WriteLine("Welcome, " + msg); }); hubConnection.StartAsync(); hubConnection.SendAsync("JoinNotificationGroup", CurrentUser.Id); }); td.IsBackground = true; td.Start(); }