Hi,
I have a list of task
List<Task> lstTasks = new List<Task>();
I am adding a method to execute into the lstTasks as below
lstTasks.Add(GetTasks(() => GetTasksToExecute()));
GetTasks() method is as below
private Task GetTasks<T>(Func<T> WorkMethod)
{
return Task.Factory.StartNew(WorkMethod);
}
GetTasksToExecute method is as below
private void GetTasksToExecute()
{
}
When i executed FxCop, it gave me issue CA1822 for GetTasks() and GetTasksToExecute() method
To fix this issue, i found that these 2 method needs to be marked as static
My Question:
1. If i mark them as static will it cause any issue in TPL?
2. Is it good to exclude this rule for these 2 methods (using code line [SuppressMessage]....) ?
3. Does this rule means i need to modify all the
private
methods in my class to
private static
which do not access instance member of that class?
One more important thing:
According to answer posted in the below post: "
2.As you are not using the instance from the method, it doesn't affect the status of thread safety. As the method only uses the data that is sent to it, it is thread safe.
"
Is this true?
http://stackoverflow.com/questions/6483720/code-analysis-c-sharp-net-ca1822[
^]