One of the great sessions at Codemash was a dual-speaker session with Bill Wagner and Jon Skeet—Async from the Inside. In that session Bill and Jon describe (in great detail) the state machine that the C# compiler generates when it compiles async code involving the await keyword. When the Async CTP was released this state machine was one of the first things I noticed when I was reflecting through some generated code. I too noticed the type of the state variable (int) and wondered, at the time, if that would be an issue. All the information Bill, Jon and I … Continue reading C#, Async, Limits, oh my!
Some things to keep in mind when writing units tests for code that use async methods: You’re not trying to test the framework’s “awaitability” and you’re not trying to test framework methods that are “awaitable”. You want to test your code in certain isolation contexts. One context, of course, is independent of asynchronicity–do individual units of code that don’t depend on asynchronous invocation “work”… e.g. “Task<string> MyMethodAsync()”, you want to have a unit test that make sure this method does what it’s supposed to do (one being it returns a “valid” Task<string> object, the other being that individual side-effects occur, … Continue reading Testing Strategies Involving Async Functions
In my last post I showed .Net 1.1 and .NET 2.0 code that performed some asychronous operations. I then showed the new syntax with “async” and “await” that did the same thing. But, I didn’t detail what’s really going on in the new syntax. If you want to know more about the details of what’s going on, read on. If you just trust me about the previous code, you don’t have to read on 🙂 When the Click handler is executed it basically executes everything up to the first await and returns. This allows the UI to be responsive. The … Continue reading More on Async Functions