I have asp.net core controller that gets data from View and make search with it
Here is controller code
 private readonly GettingWords _repository;
    public HomeController(GettingWords repository){
        _repository = repository;
    }
    [HttpPost]
    public JsonResult SearchWord([FromBody] RequestModel model){
        var result = _repository.GettingWord(model.word, model.adress);
        return Json(result);
    }
Here is method that it calls
public class GettingWords
{
    public string  GettingWord(string word, string adress)
    {
        string result;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(adress);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream receiveStream = response.GetResponseStream();
        StreamReader readStream = null;
        if (response.CharacterSet == null)
        {
            readStream = new StreamReader(receiveStream);
        }
        else
        {
            readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
        }
        string data = readStream.ReadToEnd();
        string pattern = word;
        // Instantiate the regular expression object.
        Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
        // Match the regular expression pattern against your html data.
        Match m = r.Match(data);
        if (m.Success)
        {
            result = "Word  " + word + "  finded in  " + adress;
        }
        else
        {
            result = "Word not finded";
        }
        response.Close();
        readStream.Close();
        return result;
    }
}
I need to run GettingWord in new Thread with those two parameters. How I can do this correctly?
UPDATE
Also I need to set max number of threads, so I think just Task<> is not great for this
 
     
    