We've upgraded our code base to use async/await, but many previously working methods now crash as a result of the new asynchronous code (HttpContext = null being a common issue). I'm not sure how to get around this IComparer.Compare() method. Any ideas? Seems I cannot use async Task on the Compare method:
public int Compare(myClass x, myClass y)
{
int someInteger;
// Standard, boring sorting code here.
// This is an MVC application calling into an Async method() here...
var xx = x.CallNewAsyncMethod();
var yy = y.CallNewAsyncMethod();
// Work with xx and yy now...
return someInteger;
}
If I cannot get around making this .NET IComparer.Compare() method async, are there any other alternatives (such as LINQ) I could use to sort my classes? One thing to note, I've simplified the above code, but there's really a lot going on in there and our sorting code is not trivial. There are about 10 different kinds of sorts we could use and each sort is really a three level sort (sort by a, then b, then c).
Thanks for your help!