Public Class GenericUIActionIsCancelableUIModel
    Private Sub _startdatalistaction_InvokeAction(sender As Object, e As Blackbaud.AppFx.UIModeling.Core.InvokeActionEventArgs) _
        Handles _startdatalistaction.InvokeAction

        _startdatalistaction.Enabled = False
        Me.MESSAGE.Value = ""

        ' You will need to load this data list via Load Spec before you attempt to call it with the code below.  
        ' See LongRunning.DataList.xml within the SpDataList.Catalog vb project
        '** Important **
        ' In the request below, note the setting of the .CancelID property value
        ' using the e.CancelID property on the UIModeling.Core.InvokeActionEventArgs 
        ' which gets passed into the InvokeAction event handler for that UIAction
        '** Important **
        ' As of SDK 3.0, only DataListLoad and CodeTableEntryDelete implement 
        ' ICancelAsync and therefore are the only service methods that honor the .CancelID property.
        Dim request As New Server.DataListLoadRequest() With {.DataListName = "Long Running Data List (custom)", _
                   .SecurityContext = Me.GetRequestSecurityContext, _
                   .CancelID = e.CancelId}

        request.ClientAppInfo.TimeOutSeconds = 0

        'The higher the loop count the longer it will take to run the sp for the data list.
        Dim params = New XmlTypes.DataForms.DataFormItem()
        params.Values.Add("LOOPCOUNT", Me.LOOPCOUNT.Value.ToString)

        request.Parameters = params

        Dim svc = New Blackbaud.AppFx.Server.AppFxWebService(GetRequestContext())

        'Here is the call to the data list.
        'If the user selects Cancel on the "Loading..." dialog screen, the operation is cancelled. 
        'We can inspect the reply's DataListLoadWasCancelled property to determine if the cancel occured.
        Dim reply = svc.DataListLoad(request)

        If Not reply.DataListLoadWasCancelled Then
            Me.MESSAGE.Value = "Data list was NOT cancelled"
        Else
            Me.MESSAGE.Value = "Data list WAS CANCELLED BY USER"
        End If
        _startdatalistaction.Enabled = True
    End Sub
End Class