Controllers and threads

Posted by user72185 on Stack Overflow See other posts from Stack Overflow or by user72185
Published on 2010-04-05T17:13:35Z Indexed on 2010/04/05 17:23 UTC
Read the original article Hit count: 391

Hi, I'm seeing this code in a project and I wonder if it is safe to do:

(ASP.NET MVC 2.0)

class MyController
{
  void ActionResult SomeAction()
  {
    System.Threading.Thread newThread = new System.Threading.Thread(AsyncFunc);
    newThread.Start();
  }

  void AsyncFunc()
  {
    string someString = HttpContext.Request.UrlReferrer.Authority + Url.Action("Index", new { controller = "AnotherAction" } );     
  }
}

Is the controller reused, possibly changing the content of HttpContext.Request and Url, or is this fine (except for not using the thread pool).

Thanks for info!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about thread-safety