How do you call a generic method on a thread?
Posted
by cw
on Stack Overflow
See other posts from Stack Overflow
or by cw
Published on 2010-03-27T03:16:10Z
Indexed on
2010/03/27
3:23 UTC
Read the original article
Hit count: 336
How would I call a method with the below header on a thread?
public void ReadObjectAsync<T>(string filename)
{
// Can't use T in a delegate, moved it to a parameter.
ThreadStart ts = delegate() { ReadObjectAcync(filename, typeof(T)); };
Thread th = new Thread(ts);
th.IsBackground = true;
th.Start();
}
private void ReadObjectAcync(string filename, Type t)
{
// HOW?
}
public T ReadObject<T>(string filename)
{
// Deserializes a file to a type.
}
© Stack Overflow or respective owner