Пример #1
0
 public void writeInfo(MainWindow con, Label tsslInfo, string text)
 {
     if (!tsslInfo.CheckAccess())
     {
         con.Dispatcher.Invoke(DispatcherPriority.Send,
         (Action)delegate
         {
             tsslInfo.Content = text;
         });
     }
     else
         tsslInfo.Content = text;
 }
Пример #2
0
        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());
                }
            }
        }
Пример #3
0
 public static void UpdateLabel( Label label, string content )
 {
     if (label.CheckAccess()) myUpdateLabel( label, content );
     else label.Dispatcher.BeginInvoke( new dUpdateLabel( myUpdateLabel ), new object[] { label, content } );
 }