public Person(string n, string c, bool s, string ip, int port, int key, int rnd) { t = new System.Timers.Timer(5000); this._Name = n; this._Surname = c; this._State = s; this.ip = IPAddress.Parse(ip); this._Port = port; this._Rnd = rnd; t.Elapsed += OnTimeElapse; t.AutoReset = true; t.Start(); _Keyimage = key; _ImageName = SharedVariables.GetImageNameGivenKey(key); _imageData = new BitmapImage(new Uri(SharedVariables.images[key])); _imageData.Freeze(); }
void Worker_DoWork(object sender, DoWorkEventArgs e) { Uploaded = 0; foreach (Person user in this.SelectedItems) { if (client != null && this.client.Annulla == true) { break; } this._user = user; try { this.client = new FtpClient(SharedVariables.Luh.Admin.GetAuthString(), "", (sender as BackgroundWorker)); client.Upload(SharedVariables.PathSend, user.GetIp().ToString()); AlreadySent++; while (!Continue) { Thread.Sleep(500); } this.Continue = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Errore connessione", MessageBoxButton.OK, MessageBoxImage.Error); MainWindow.UpdateUsers(SharedVariables.getOnline().Values); this.Dispatcher.Invoke(new Action(() => { if (this.AlreadySent > this.NumberOfSelectedItems) { this.Close(); } })); } } }