private void HostBtn_Click(object sender, EventArgs e) { if (!Hosted) { try { SessionHandler.SDList[selectedIndex].LastTimeUsed = DateTime.Now.ToString("MM/dd/yyyy HH:mm"); SessionHandler.SDList[selectedIndex].LA = LaunchedAs.Host; LogHandler.ChangeSession(SessionHandler.SDList[selectedIndex].SessionName); UIHandler.ToggleProgressBarVisibility(true); Hosted = true; HostBtn.Text = "Close"; s = new Host(currentTcpSettings); s.Start(); LogHandler.LCW.Write("Host started", "Host", "Start"); } catch (Exception ex) { LogHandler.LCW.Write(ex, "Host", "Start"); throw ex; } } else { try { Hosted = false; s.Stop(); HostBtn.Text = "Host"; LogHandler.LCW.Write("Host Stopped", "Host", "Stop"); } catch (Exception ex) { LogHandler.LCW.Write(ex, "Host", "Stop"); throw ex; } } }
private void JoinBtn_Click(object sender, EventArgs e) { //if (!Joined) //{ //========== future feature try { SessionHandler.SDList[selectedIndex].LastTimeUsed = DateTime.Now.ToString("MM/dd/yyyy HH:mm"); SessionHandler.SDList[selectedIndex].LA = LaunchedAs.Joined; LogHandler.ChangeSession(SessionHandler.SDList[selectedIndex].SessionName); UIHandler.ToggleProgressBarVisibility(true); Joined = true; c = new Joined(currentTcpSettings); c.Connect(); LogHandler.LCW.Write("Joined connected", "Joined", "Start"); // Starting syncronization as a background thread so it does not freeze the main form. InstanceCaller = new Thread(new ThreadStart(c.Syncronize)); InstanceCaller.IsBackground = true; // Start the thread. InstanceCaller.Start(); } catch (Exception ex) { LogHandler.LCW.Write(ex, "Joined", "Start"); throw ex; } //} //else //{ // Joined = false; // InstanceCaller.Abort(); // c.Disconnect(); //} }