1

This is a continuation of

Prevent IIS from killing a Task before it ends

My question:

Given

public static Task StartNew(Action act)
{
    IISNotifier notif = new IISNotifier(); -> HostingEnvironment.RegisterObject(this);
    notif.Started();
    return Task.Factory.StartNew(() => {
        act.Invoke();
        notif.Finished(); ->  HostingEnvironment.UnregisterObject(this);
    });
}

Invoked by

    return new LogResult(id, IISTaskFactory.StartNew(() => 
        DoLogInAzure(account, id, exception, request))
    );

Example implementation

    DoLogInAzure(account, id, exception, request)) {

            DoSomeLongOperation()
            **Thread.Yield()**
             DoLogInAzure();

    }

The above is just example code. To illustrate Thread.Yield statement Ive made it recursive.

Question Please bear in mind this is running in a Azure web role or potentially an Azure website. 1.) What does the Thread.Yield() statement actually do in the context of IIS in the above example? 1a.) I would assume it would allow the thread to service other incoming requests 1b.) Would it allow IIS to tear down the thread i.e. would the recursion stop?

Many thanks, especially to Gervasio Marchand, Damian Schenkelman and that blog post of Phil Haack and to you too if you can answer it :)

Community
  • 1
  • 1

0 Answers0