The question is how to pass a function with a parameter to the Task or Task class; all methods are interested. Thank.

  • Describe what you want to do and attach the code where you tried to do it. Or google. - MihailPw
  • What does it mean to "transfer to the class Task "? Describe what you are doing and what you want to receive. - VladD
  • You need to create a Task, so that it accepts a delegate that can accept an argument. - Stanislav Petrov

1 answer 1

You probably need something like this.

 private void RunAsync() { string param = "Hi"; Task.Run(() => MethodWithParameter(param)); } private void MethodWithParameter(string param) { //Do stuff }