Nonblocking Calls

Asynchronous communication is supported in Windows 2000 by a feature that is called nonblocking calls, which allows a client to request a lengthy operation without being blocked. In other words, the client can proceed with further processing after requesting the operation. The server component will notify the client when the lengthy operation is completed. Windows 2000 supports asynchronous invocation via a new MIDL interface attribute called async_uuid. An example of an asynchronous interface is shown here:

[ object, uuid(D9F23D61-A647-11d1-ABCD-00207810D5FE),
  async_uuid(AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA) ]
interface IOcr : IUnknown {
    HRESULT OcrImage([in] long lImageSize,
                     [in, size_is(lImageSize)] byte * pbImage,
                     [out, string] wchar_t **pwszOcrText);
}

Because this MIDL snippet uses the async_uuid attribute, MIDL will generate two interface definitions for the IOcr interface: a normal (synchronous) version and an asynchronous version. You are familiar with the synchronous version:

interface IOcr : public IUnknown {
public:
   virtual HRESULT OcrImage(
      /* [in] */ long lImageSize,
      /* [size_is][in] */ byte *pbImage,
      /* [string][out] */ wchar_t **pwszOcrText) = 0;
};

But you’ve never seen the asynchronous version:

interface AsyncIOcr : public IUnknown {
public:
   virtual HRESULT begin_OcrImage(
      /* [in] */ long lImageSize,
      /* [size_is][in] */ byte *pbImage) = 0;
   virtual HRESULT finish_OcrImage(
      /* [string][out] */ wchar_t **pwszOcrText) = 0;
};

The asynchronous version ...

Get Learning DCOM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.