0

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...

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
0

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 by Mitja Bonca: n/a

0

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

0

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

Edited by Ketsuekiame: n/a

0

thx Ketsuekiame.
I wasnt around this morning...

I am glad it does.
bye.

Edited by Mitja Bonca: n/a

This article 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.