Click here to Skip to main content
12,754,309 members (28,835 online)

Abort the asynchronous operation

Makso asked:

Open original thread
Hi,
Can anybody tell me how to abort the asynchronous operation?

Problem such.

I have created the application which gathers some information from different databases. And this process can be very durable, therefore I call procedure of collection asynchronous that there was a possibility it to interrupt at any time.

That I have made:
Public class Manager

    Public Sub ImportTransfers
        'Collect information
    End Sub

End class

Public Class frm_Main

    Delegate Sub dlg_Importer()
    Dim Importer As dlg_Importer
    Dim CallBackImport As AsyncCallback

    Private Sub frm_Main_Load
          Call Init_Delegates()
    End Sub

        Private Sub Init_Delegates()
          Importer = AddressOf Manager.ImportTransfers
          CallBackImport = AddressOf CallBack_Import
        End Sub

        Private Sub btn_ImportTransfers_Click
          Importer.BeginInvoke(CallBackImport, Nothing)
    End Sub

        Sub CallBack_Import(ByVal ar As IAsyncResult)
          Importer.EndInvoke(ar)
        End Sub

        Private Sub btn_StopProcess_Click
           'I do not know what to write here to stop process...
        End Sub

End Class


The CallBack_Import procedure is fulfilled after ImportTransfers procedure end, but how to stop ImportTransfers by button btn_StopProcess Click?
Tags: VB, VB.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100