简体   繁体   中英

How to stop SSAS cube processing programatically?

We are using Microsoft.AnalysisServices library to access our SSAS database (on SQL Server 2014) and programatically process cubes.

The code looks like this:

using (var server = new Server())
{
    server.Connect("someserver");

    if (server.Connected)
    {
        var db = server.Databases.FindByName("somedb");

        if (db != null)
        {
            db.Process(ProcessType.ProcessFull);
        }
    }
}

The problem is, full cube processing may take a long time (in our case over 1h). And we need a way to gracefully stop/cancel it if necessary (the code above is a part of complex Windows Service that sometimes needs to be restarted).

It is completely acceptable that interrupting the task results in cube not being processed.

Is there a way to write the code above so it is non-blocking? Or pass a callback somehow? I could not find anything relevant in MSDN documentation:

https://msdn.microsoft.com/en-us/library/microsoft.analysisservices.database.aspx

Can you try getting rid of the using block and making your server object a class level member. Then try this on the cancel thread:

server.CancelSession(server.SessionID);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM