Click here to Skip to main content
13,147,037 members (59,481 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi experts, i wanna ask u about multithread with some parameters. I've a problem when i want to send some parameters. :(

I have three methods and three parameters in each other :

private void SendAckDetail(string memberID, string partName, string AccNum)
  //-- process
private void InsertToDB(string bankCode, string partName, string AccNum)
  //-- process
private void CreateXMLData(int totalRec, string ExtRef, string Curcod)
  //-- process

I've tried this methode to handle multithread with some parameters but it hasn't worked properly... :confused:

oThread1 = new Thread(delegate() { SendAckDetail(memberID, partName, AccNum); });
oThread2 = new Thread(delegate() { InsertToDB(bankCode, partName, AccNum); });
oThread3 = new Thread(delegate() { CreateXMLData(totalRec, ExtRef, Curcod); });

Would u help me please experts ??... :confused: :confused:
Posted 15-Aug-10 17:55pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can try like following.

class Program
        static void Main(string[] args)
            ThreadTest t = new ThreadTest();
            Acknowledgement acknowledgement= new Acknowledgement();
            acknowledgement.AccNum = "123";
            acknowledgement.MemberID = "M123";
            acknowledgement.PartName = "P23432";
            Thread oThread1 = new Thread(t.SendAckDetail);
    struct Acknowledgement
        public string MemberID { get;  set; }
        public string PartName { get; set; }
        public string   AccNum { get; set; }
    class ThreadTest

        public void SendAckDetail(object ack)

Similarly you can do this for other methods also.
Teamsar 16-Aug-10 1:17am
ParameterizedThreadStart has a method void(obj). If i use this code :
oThread1 = new Thread (new ParameterizedThreadStart(SendAckDetail));
There are many errors occur.. :(
Prakash Kalakoti 16-Aug-10 2:00am
I have updated the answer, you can do like as mentioned in the answer.
Teamsar 16-Aug-10 3:25am
Reason for my vote of 5
This code is helpful for me.
Teamsar 16-Aug-10 3:26am
Thank you Prakash Kalakoti :), this code is very helpful for me.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 16 Aug 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100