Exemplo n.º 1
0
            private static void ClientThreadFunc(object data)
            {
                Console.WriteLine("Client thread started");
                ClientThread ct = data as ClientThread;

                ct.Run();
            }
Exemplo n.º 2
0
        private void buttonRegister_Click(object sender, EventArgs e)  /*
                                                                        * byte[] salt = GenerateSalt(SALTSIZE);
                                                                        * textBoxSalt.Text = Convert.ToBase64String(salt);
                                                                        * textBoxSizeSalt.Text = (salt.Length * 8) + "";
                                                                        *
                                                                        * byte[] password = Encoding.UTF8.GetBytes(textBoxPassword.Text);
                                                                        * byte[] hash = GenerateSaltedHash(password, salt);
                                                                        *
                                                                        *
                                                                        * textBoxSizePass.Text = (hash.Length * 8) + "";
                                                                        * textBoxSaltedHash.Text = Convert.ToBase64String(hash);
                                                                        *
                                                                        * Register(textBoxUsername.Text, hash, salt);*/
        {
            ClientThread ct = new ClientThread("Thread 1");

            ct.Run();

            ClientThread ct2 = new ClientThread("Thread 2");

            ct2.Run();
        }
        public MainWindowClient()
        {
            BindingErrorListener.Listen(m => {
                if (!m.Contains("FindAncestor"))
                {
                    var s = m;
                    var t = new Thread(() => MessageBox.Show(s));
                    Console.WriteLine(m);
                    t.Start();
                }
            });
            InitializeComponent();
            _applicationPresenter = new ApplicationPresenter();
            SaveExecuteHelper.Get().Dispatcher = Dispatcher;
            for (int i = 1; i <= _applicationPresenter.Settings.ClientSettings.NumberOfThreads; i++)
            {
                string workingDir = _applicationPresenter.Settings.ClientSettings.WorkingDirectory;
#pragma warning disable CA2000 // Dispose objects before losing scope
                string     logfilename = Path.Combine(workingDir, "DistCalc.Client." + i + ".Log.sqlite");
                DistLogger logger      = new DistLogger(logfilename, "Log", null);
#pragma warning restore CA2000 // Dispose objects before losing scope
                Settings cs = new Settings(_applicationPresenter.Settings);
                cs.ClientSettings.WorkingDirectory = Path.Combine(cs.ClientSettings.WorkingDirectory, "c" + i);
                ClientThread ct = new ClientThread(logger, cs, new ThreadId(Environment.MachineName, i));
                _clientThreads.Add(ct);
                var t = new Thread(() => ct.Run(ShowMessageBox));
                _threads.Add(t);
                t.Start();
                TabItem ti = new TabItem();
                ti.Header = "Client " + i;
                ClientView      cv = new ClientView();
                ClientPresenter cp = new ClientPresenter(ct, this);
                cv.DataContext = cp;
                ti.Content     = cv;
                MyTabControl.Items.Add(ti);
            }
        }