hi all
i try to send data into Thread function - the data is : string[][] DataTimes
but i get eror!!!

this my function that Start the Thread:

Thread newThread = new Thread(Form1.PlayTheClock);
            newThread.Start(DataTimes);

that the Thread Function:

public static void PlayTheClock(string[][] DataTimes)
        {
......
}

the problem is : Error 1 The best overloaded method match for 'System.Threading.Thread.Thread(System.Threading.ParameterizedThreadStart)' has some invalid arguments

thanks...

If no parameters to pass:

//1. way:
 new Thread(new ThreadStart(MethodNoParams)).Start();//calling new method

//2. longer way (if you need a "t" variable maybe):
Thread t = new Thread(new ThreadStart(MethodNoParams)); //calling new method
t.Start();

If parameters to pass:

object obj ="some param";
Thread t1 = new Thread(new ParameterizedThreadStart(MethodWithParams)); //calling new method
t1.Start(obj);

MethodNoParams is a method that accepts no parameters, while MethodWithParams is a method which accpets parameter.
Just for your knowledge:

private void MethodNoParams()
        { 
        
        }

        private void MethodWithParams(object args)
        { 
        
        }

Edited 5 Years Ago by Mitja Bonca: n/a

hi thanks
but i dont know how to convert (string[][] DataTimes) to (Object)
and (Object) to (string[][] DataTimes).

You literally just did it in that post. =p (Object)DataTimes (String[][])args

Edited 5 Years Ago by Ketsuekiame: n/a

thx Ketsuekiame.
I wasnt around this morning...

I am glad it does.
bye.

Edited 5 Years Ago by Mitja Bonca: n/a

This article has been dead for over six months. Start a new discussion instead.