Context.CheckCancelled 方法

Throws an exception if the query has timed out or been canceled by the user.

命名空间:  Microsoft.AnalysisServices.AdomdServer
程序集:  msmgdsrv(在 msmgdsrv.dll 中)

语法

声明
Public Shared Sub CheckCancelled
用法
Context.CheckCancelled()
public static void CheckCancelled()
public:
static void CheckCancelled()
static member CheckCancelled : unit -> unit
public static function CheckCancelled()

注释

The exception raised by CheckCancelled should be handled, and then rethrown.

示例

In the following example, a UDF is defined that takes a very long time to execute. Occasionally, it calls CheckCancelled to determine if the function should exit:

public string LongRunning()
{

    try
    {
        //Enter a long running loop
        for (int nIndex = 0; nIndex < 1000; nIndex++)
        {
            //Exception generated when the query is canceled or Timeout occurs
            Context.CheckCancelled();
            System.Threading.Thread.Sleep(1000);
        }
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex.Message);
        throw ex;
    }

    return "UDF Allowed to Finish";
}

请参阅

参考

Context 类

Microsoft.AnalysisServices.AdomdServer 命名空间