public void start(string ip_adress, Action nasluch, Label tsslInfo, Button btnLoguj) { if (!tsslInfo.CheckAccess() && !btnLoguj.CheckAccess()) { con.Dispatcher.Invoke(DispatcherPriority.Send, (Action)delegate { btnLoguj.IsDefault = true; tsslInfo.Content = "Trwa łączenie....."; try { tcpclnt = new TcpClient(); tcpclnt.Connect(IPAddress.Parse(ip_adress), 9999); //tcpclnt.Connect("127.0.0.1", 9999); thread = new Thread(new ThreadStart(nasluch)) { IsBackground = true }; thread.Start(); } catch (Exception e) { tsslInfo.Content = "Error "; log.nextLog(); log.write(e.ToString()); } }); } else { btnLoguj.IsDefault = true; tsslInfo.Content = "Trwa łączenie....."; try { tcpclnt = new TcpClient(); tcpclnt.Connect(IPAddress.Parse(ip_adress), 9999); //tcpclnt.Connect("127.0.0.1", 9999); thread = new Thread(new ThreadStart(nasluch)) { IsBackground = true }; thread.Start(); } catch (Exception e) { tsslInfo.Content = "Error "; log.nextLog(); log.write(e.ToString()); } } }
private void UpdateButtonStatus( Button button, bool IsEnabled ) { if (button.CheckAccess()) myUpdateButtonStatus( button, IsEnabled ); else button.Dispatcher.BeginInvoke( new dUpdateButtonStatus( myUpdateButtonStatus ), new object[] { button, IsEnabled } ); }