Esempio n. 1
0
        private async void ThreadProcesses(object obj)
        {
            if (token2 == "")
            {
                DialogResult d;
                d = System.Windows.Forms.MessageBox.Show("Please login your account ", "Login required", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (d == System.Windows.Forms.DialogResult.Yes)
                {
                    Thread.Sleep(50);
                    FourPage fo = new FourPage();
                    fo.Show();
                    this.Hide();
                }
                if (d == System.Windows.Forms.DialogResult.No)
                {
                    Close();
                    Environment.Exit(0);
                }
            }
            else
            {
                FunctionStep1 step4 = new FunctionStep1();
                list2 = step4.GetMeJoinedTeamTo(token2);
                for (int i = 0; i < list2.Count; i++)
                {
                    await testFuction(token2, list2[i].id, 2);

                    int c = i + 1;
                    SetprogressBar2(c, list2.Count);
                    Thread.Sleep(5);
                }
            }
        }
Esempio n. 2
0
 private Task testFuction(string AccessToken, string TeamID, int typ)
 {
     return(Task.Run(() =>
     {
         FunctionStep1 step3 = new FunctionStep1();
         step3.GetMeJoinedChanel(AccessToken, TeamID, typ);
     }));
 }
Esempio n. 3
0
        public FivePage()
        {
            InitializeComponent();
            con.Open();
            SqlCommand cmd1 = new SqlCommand("select_atoken", con);

            cmd1.CommandType = CommandType.StoredProcedure;
            using (SqlDataReader reader = cmd1.ExecuteReader())
            {
                if (reader.Read())
                {
                    token1 = reader["access_token"].ToString();
                }
            }
            con.Close();

            if (token1 == "")
            {
                DialogResult d;
                d = System.Windows.Forms.MessageBox.Show("Please login your account ", "Login required", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (d == System.Windows.Forms.DialogResult.Yes)
                {
                    FourPage fo = new FourPage();
                    fo.Show();
                    this.Hide();
                }
                if (d == System.Windows.Forms.DialogResult.No)
                {
                    Close();
                    Environment.Exit(0);
                }
            }
            else
            {
                FunctionStep1 step1 = new FunctionStep1();
                list1 = step1.GetMeJoinedTeam(token1);
            }

            worker                            = new BackgroundWorker();
            worker.DoWork                    += worker_DoWork;
            worker.ProgressChanged           += worker_ProgressChanged;
            worker.RunWorkerCompleted        += worker_RunWorkerCompleted;
            worker.WorkerReportsProgress      = true;
            worker.WorkerSupportsCancellation = false;

            int maxItems = list1.Count;

            pbar.Minimum = 1;
            pbar.Maximum = 100;

            StatusTextBox.Text = "Starting...";
            worker.RunWorkerAsync(maxItems);
        }
Esempio n. 4
0
 void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     if (list1 != null)
     {
         BackgroundWorker worker = sender as BackgroundWorker;
         int?maxItems            = e.Argument as int?;
         for (int i = 0; i < list1.Count; i++)
         {
             string        tid = list1[i].id;
             FunctionStep1 f   = new FunctionStep1();
             f.GetMeJoinedChanel(token1, tid, 1);
             Thread.Sleep(50);
             int c = i + 1;
             worker.ReportProgress(c);
         }
     }
 }