I have written the following code:
var threaddatatable = new System.Threading.Thread(update);
threaddatatable.Start(dt);
update(datatable dt)
{
}
But I am receivi开发者_运维知识库ng these errors:
The best overloaded method match for System.Threading.Thread.Thread(System.Threading.ThreadStart)has some invalid arguments
And
Argument 1 cannot convert from 'method group' to System.Threading.ThreadStart
How can I assign my update
method to my thread?
The signature takes object; you need
new Thread(obj => update((DataTable)obj));
I also suggest looking at either the ThreadPool or TPL/Task - threads are relatively expensive.
you should rewrite your code like this
var threaddatatable = new System.Threading.Thread(new System.Threading.ThreadStart( update)); threaddatatable.Start();
精彩评论