I have this class:
public class Statistics
{
List<string> _lsit;
public List<string> ipList
{
get { return _lsit; }
set { _lsit = value; }
}
string _Path = @"C:\Program Files\myApp.exe";
string _Path = "";
ProcessStartInfo ps = null;
public getStatistics(string Path)
{
_Path = Path;
getStatistics();
}
}
I want to start the function Statistics with different Thead and i did somthing like:
Statistics stat = new Statistics (some path);
Thread<List<string>> lList = new Thread<List<string>>(() => tsharkIps.getStatistics());
but the compiler Error says “The non-generic type ‘System.Threading.Thread’ cannot be used with type arguments”
I did not write all my class and only want to know hot to start the thread
thanks
You need to take a step back to start with and read the compiler error.
Threadis not a generic type. It’s really not at all clear what you’re trying to do here, especially as you haven’t even shown a parameterlessgetStatistics()method (which should be calledGetStatistics()to follow .NET naming conventions) and the parameterizedgetStatistics()method you have shown doesn’t have a return type.Starting a thread with a lambda expression is the easy part:
It’s not clear how that translates to your sample code though.
Or using the TPL in .NET 4, you can (and probably should use
TaskorTask<T>):or
It’s possible that you really want:
Note that here the constructor is called within the new task – which is important, as it looks like that’s probably doing all the work. (That’s usually a bad idea to start with, but that’s another matter.)
You should look at .NET naming conventions in general, btw…