0

I've been looking for the past few days on how to do this but I just can't figure out what the correct way to assign a variable that will stay with the class

Any help will be appreciated.

private void button1_Click(object sender, EventArgs e)
        {
            tempclass tempclass = new tempclass();

            Thread t = new Thread(tempclass.add);
            string[] stuff = {"one 1", "two", "three"};
            t.Start(stuff);

            tempclass.show();
        }

     }

    class tempclass
    {
        public string data;

        public void add(object param)
        {
            string[] pams = (string[])param;
            MessageBox.Show(pams[0]);
            data = pams[0];
        }

        public void show()
        {
            MessageBox.Show(data);
        }
    }
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
0

Use BackgroundWorker component which is use for multithreading tasks you can call the method by name and send the parameters in array of objects.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.