Exemplo n.º 1
0
 private void ParallelImageStatus(IContract client, ProgressChecker checker, CancellationToken cancellation)
 {
     try
     {
         int progress = 0;
         Thread.Sleep(900);
         while (progress < 100)
         {
             progress         = client.GetStatus();
             checker.Progress = progress.ToString() + " %";
             App.Current.Dispatcher.Invoke(() =>
             {
                 if (progress < 100)
                 {
                     progressBar.Value = progress;
                 }
                 else
                 {
                     progressBar.Value = 100;
                     if (progress < 0)
                     {
                         checker.Progress = "Error in progress";
                         Thread.Sleep(3000);
                     }
                 }
             });
             Thread.Sleep(800);
         }
         checker.Progress = "all done";
         Thread.Sleep(800);
         App.Current.Dispatcher.Invoke(() =>
         {
             buttonSend.IsEnabled        = true;
             buttonImageSelect.IsEnabled = true;
             buttonSave.IsEnabled        = true;
             comboBoxFilter.IsEnabled    = true;
         });
     }
     catch (Exception e)
     {
         if (cancellation.IsCancellationRequested)
         {
             return;
         }
         MessageBox.Show("Error in parallelStatusClient\n" + e.Message);
     }
     return;
 }
Exemplo n.º 2
0
        public MainWindow()
        {
            ip = "localhost";
            InitializeComponent();
            buttonImageSelect.IsEnabled = true;
            labelControl = new ProgressChecker();
            labelProgress.DataContext = labelControl;
            labelControl.Progress     = "prgress precent";
            imageControl             = new ImageChecker();
            boxImageShow.DataContext = imageControl;
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, false);

            binding.MaxBufferSize          = int.MaxValue;
            binding.MaxReceivedMessageSize = int.MaxValue;
            factory = new ChannelFactory <IContract>(binding, new EndpointAddress($"net.tcp://{ip}:12345/srv"));
            client  = factory.CreateChannel();

            try
            {
                string[] filters = client.GetFilters();
                foreach (var filter in filters)
                {
                    comboBoxFilter.Items.Add(filter);
                }
                if (filters.Length < 1)
                {
                    throw new Exception("No Filters found");
                }
                comboBoxFilter.SelectedItem = comboBoxFilter.Items[0];
                buttonImageSelect.IsEnabled = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }