xlAsyncReturn

適用対象: Excel 2013 | Office 2013 | Visual Studio

非同期ユーザー定義関数 (UDF) の結果を返すために使用します。

Excel12(xlAsyncReturn, LPXLOPER12 pxRes, 2, LPXLOPER12 pxAsyncHandle, LPXLOPER12 pxFunctionResult);

パラメーター

pxAsyncHandle (xltypeBigData)

結果を返す先の UDF の非同期ハンドルです。

pxFunctionResult

UDF の戻り値です。

プロパティ値/戻り値

成功した場合、TRUE (xltypeBool) を返します。 失敗した場合は、FALSE を返します。

注釈

xlAsyncReturn は、再計算中に計算以外のスレッドで Excel が使用を許可する唯一のコールバックです。 非同期 UDF の非同期な部分が、xlAsyncReturn 以外のいかなるコールバックも実行しないようにする必要があります。 XLL は、戻り値を保持するために、割り当てられたメモリを解放する必要があります。

pxAsyncHandle パラメーターと pxFunctionResult パラメーターは、1 つのコールバックでハンドルと対応する値の配列を返すために使用する場合、xltypeMulti 型にすることもできます。 シングル コールバックを使用するときは、非同期ハンドルと戻り値を含む 1 次元の配列からなる XLOPER12 構造を指す LPXLOPER12 を渡します。 これらの配列は、非同期ハンドルが対応する値と正しく一致するよう、Excel に対して同じ順序である必要があります。

次の例は、xlAsyncReturn を使用して、バッチ呼び出しを作成する方法を示しています。

int batchSize = 10;
    LPXLOPER12 pHandles = new XLOPER12[batchSize];
    LPXLOPER12 pValues = new XLOPER12[batchSize];
    /*Add code to fill in LPXLOPER12 arrays (pHandles and pValues)
    with the XOPER12 structures that contain the asynchronous handles
    and values, in respective order*/
    //Create an XLOPER12 of type xltypeMulti, and fill the Handle array
    XLOPER12 handleArray;
    handleArray.xltype = xltypeMulti;
    handleArray.val.array.rows = 1;
    handleArray.val.array.columns = (COL)batchSize;
    handleArray.val.array.lparray = pHandles;
    
    //Create an XLOPER12 if type xltypeMulti, and fill the Values array
    XLOPER12 valueArray;
    valueArray.xltype = xltypeMulti;
    valueArray.val.array.rows = 1;
    valueArray.val.array.columns = (COL)batchSize;
    valueArray.val.array.lparray = pValues;
    //Make the callback with the return value
    int ret = Excel12(xlAsyncReturn, 0, 2, &handleArray, &valueArray);
    //Add code to free the allocated memory here (pHandles, pValues, valueArray, handleArray)
    return ret;

関連項目