public async void GetHomeObject() { Shared.Classes.Home localHome = new Shared.Classes.Home(); Shared.Classes.Home remoteHome = new Shared.Classes.Home(); //Get local Home object try { MyHome = Shared.Classes.Home.LoadHome().Result; } catch (Exception ex) { Debug.WriteLine(ex.Message); } //Get Remote Home Object //Hostname has to be outsourced in Config data or somewhat //Shared.Communication.TCP_Connect tcpcon = new Shared.Communication.TCP_Connect(new HostName("minwinpc")); //await tcpcon.Connect(); //await tcpcon.Send(Shared.Classes.Serializer.Serialize("getHome")); //await //string resp = tcpcon.Read().Result; //tcpcon.socket.InputStream; //if(remoteHome.LastUpdate > localHome.LastUpdate) //{ // MyHome = remoteHome; //} //tcpcon.Disconnect(); }
public MainPage() { this.InitializeComponent(); //Load Home Object try { MyHome = Shared.Classes.Home.LoadHome().Result; Logs.Add(new Shared.Classes.Log("Home Loaded.")); } catch (Exception ex) { Logs.Add(new Shared.Classes.Log(ex.Message)); } //Establish Networking try { EstablishNetworking(); Logs.Add(new Shared.Classes.Log("Server Running")); } catch (Exception ex) { Logs.Add(new Shared.Classes.Log(ex.Message)); } //Start Task that updates Logs (OPTIMIZE) Task.Factory.StartNew(async() => { while (true) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () => { //Has to be optimized txb_Events.Text = String.Empty; foreach (Shared.Classes.Log LogEntry in MainPage.Logs) { if (LogEntry.Entry != null) { txb_Events.Text += String.Concat(LogEntry.Timestamp.ToString(), ": "); txb_Events.Text += String.Concat(LogEntry.Entry.ToString(), "\n"); } } }); await Task.Delay(500); } }); }