Yusuf Karatoprak

Yusuf Karatoprak

  • NA
  • 2.5k
  • 1m

multi-thread with parameter but how?

Dec 31 2008 3:24 AM
Hi; i want ot learn how can i start threading  with parameter?

This is simple methods : (without parameter)


ThreadStart ts1 = new ThreadStart(UpdateAndInsertDbase);
            Thread t1 = new Thread(ts1);
            t1.Start();
            ThreadStart ts1;


This is complex form : (with parameter)


            Thread t1 = new Thread(new ThreadStart(new UpdateAndInsertDbase(
                new WaitCallback(UpdateAndInsertDbase), NessusID, Split1, Split2, spenglish, spturkish, conn)));
            t1.Start();

But this does not work well.

whole codes here
. . . . . .
. . . .
. . .
. .
.

 Thread t1 = new Thread(new ThreadStart(new UpdateAndInsertDbase(
                new WaitCallback(UpdateAndInsertDbase), NessusID, Split1, Split2, spenglish, spturkish, conn)));
            t1.Start();
       }
        void UpdateAndInsertDbase(string NessusID, string[] Split1, string[] Split2, string spenglish, string spturkish, string conn)
        {
            progressBar1.Minimum = 1;
            progressBar1.Maximum = Split1.Length;
            TableFromSQL sql = new TableFromSQL();

            for (int i = 0; i < Split1.Length; i++)
            {
                progressBar1.Value = i + 1;
                sql.AddToDbase(spenglish, conn, NessusID, Split1[i]);
                System.Threading.Thread.Sleep(500);
                Application.DoEvents();
            }
            for (int i = 0; i < Split2.Length; i++)
            {
                progressBar1.Minimum = 1;
                progressBar1.Value = i + 1;
                System.Threading.Thread.Sleep(500);
                Application.DoEvents();
                sql.AddToDbase(spturkish, conn, NessusID, Split2[i]);
            }
            sql.UpdateToDbase("sp_UpdateDbaseAll", conOwn);
        }

 Sortly ; i want to learn multithread with parameter.Help please?

Answers (3)