Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int max = 1000;

            this.errors = 0;
            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = max - 1;
            for (int i = 0; i < max; i++)
            {
                Thread t = new Thread(new ThreadStart(
                                          delegate()
                {
                    using (sr.CacheServiceClient csc = new NetSqlAzMan_WinTest.sr.CacheServiceClient())
                    {
                        try
                        {
                            csc.Open();
                            //KeyValuePair<string, string>[] attrs = null;

                            AuthorizationType auth = csc.CheckAccessForWindowsUsersWithoutAttributesRetrieve("Eidos", "DB Persone",
                                                                                                             "Gestore", WindowsIdentity.GetCurrent().GetUserBinarySSid(), WindowsIdentity.GetCurrent().GetGroupsBinarySSid(),
                                                                                                             DateTime.Now, false, null);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            if (ex.InnerException != null)
                            {
                                MessageBox.Show(ex.InnerException.Message);
                            }
                            this.errors++;
                        }
                        finally
                        {
                            ((IDisposable)csc).Dispose();
                        }
                    }
                    Thread.Sleep(new Random().Next(300));
                }));
                this.progressBar1.Value = i;
                Application.DoEvents();
                t.Start();
                Thread.Sleep(new Random().Next(100));
            }
            MessageBox.Show(this.errors.ToString());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int max = 1000;
            this.errors = 0;
            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = max - 1;
            for (int i=0;i<max;i++)
            {
                Thread t = new Thread(new ThreadStart(
                    delegate()
                    {
                        using (sr.CacheServiceClient csc = new NetSqlAzMan_WinTest.sr.CacheServiceClient())
                        {
                            try
                            {
                                csc.Open();
                                //KeyValuePair<string, string>[] attrs = null;

                                AuthorizationType auth = csc.CheckAccessForWindowsUsersWithoutAttributesRetrieve("Eidos", "DB Persone",
                                    "Gestore", WindowsIdentity.GetCurrent().GetUserBinarySSid(), WindowsIdentity.GetCurrent().GetGroupsBinarySSid(),
                                    DateTime.Now, false, null);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                                if (ex.InnerException != null)
                                    MessageBox.Show(ex.InnerException.Message);
                                this.errors++;
                            }
                            finally
                            {
                                ((IDisposable)csc).Dispose();
                            }
                        }
                        Thread.Sleep(new Random().Next(300));
                    }));
                this.progressBar1.Value = i;
                Application.DoEvents();
                t.Start();
                Thread.Sleep(new Random().Next(100));
            }
            MessageBox.Show(this.errors.ToString());
        }