I'm experimenting with using async/await on WCF exposed methods/services. Everything works fine but I'd like to simulate the service method actually waiting for IO so that the service call will be registered with an IO completion port, and the thread put back into the thread pool.
To clarify, I'm just experimenting to confirm usage of IO completion ports and to get a better understanding of the mechanics of what's actually going on.
So e.g. my test service currently looks like this:
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
Task<string> SayHello(string firstName, string lastName);
}
public class HelloWorldService : IHelloWorldService
{
public async Task<string> SayHello(string firstName, string lastName)
{
string str = string.Format("Hello {0} {1}", firstName, lastName);
return await Task.Factory.StartNew(() => str);
}
}
I'd like to do something in SayHello() to cause that code to wait for some IO, ideally a code pattern I can copy/paste to use generally when I want to simulate waiting for IO.
Typically Thread.Sleep() is used to simulate a long running task, but I'm pretty sure that will put the thread pool thread to sleep and not trigger usage of an IO completion port .