I have a Windows Server 2008 R2 IIS 7 instance running .ASP.NET WebForms .NET 4.0 code. In a postback there is a thread spawn that runs a long-running process.
The below code does not work under IIS7. It works fine locally under Cassini and on another Windows Server 2003 IIS6 instance we have available.
var t = Task.Factory.StartNew(() => ProcessWorkItem(wid));
var ex = t.Exception;
Log(string.Format("Spawned background task to wid={5}: id={1} status={4} isfaulted={3} iscompleted={2} ex={0}",
ex == null ? "no exception" : ex.ToString(),
t.Id,
t.IsCompleted,
t.IsFaulted,
t.Status,
wid));
This logs "no exception" and "isfaulted=false" and "iscompleted=true" regardless of server.
However, there is also a log statement inside the ProcessWorkItem
, which is never hit on IIS7, though it is hit just fine on IIS6 or Cassini local dev server.
Any idea why that would be?