Background process is running: Exit Aborted message


David MeegoIn a recent newsgroup posting, I was helping a Visual Studio Tools developer whose users were receiving the following message when they went to exit Microsoft Dynamics GP.


Background process is running: Exit Aborted


There is a common cause for this error which is highlighted in the Visual Studio® Tools for Microsoft Dynamics™ GP Programmer’s Guide, Chapter 9: Working with Tables, in the section called Opening and closing tables.  Below is an excerpt from the manual on the subject:



There is no explicit “open” operation for a table in Visual Studio Tools. The first time a table buffer is accessed, the table is automatically opened. The table buffer remains open until it is closed.


When your integrating application’s code has finished working with a global table buffer, it must be closed using the Close() method for the table. Failing to close a global table buffer will cause a “Background process is running: Exit Aborted” error when the user attempts to exit Microsoft Dynamics GP.



What this means is that if your code references a table at the global level, a table buffer will be created for you and will not be closed until your code specifically requests it to close with the Close() method.  You must use the Close() method before the table object is destroyed (either explicitly or because the the scope no longer exists).


It is recommended to have exception handling around the table access code which will ensure that the Close() method is called even if an error occurs, see examples below:



C# Code Example


RmCustomerMstrTable CustomerMasterTable;
CustomerMasterTable = Dynamics.Tables.RmCustomerMstr;


try
{
    // Read the first row of the table
    CustomerMasterTable.GetFirst();


    // Display the name for the row retrieved
    MessageBox.Show(CustomerMasterTable.CustomerName.Value);
}
catch(Exception e)
{
    MessageBox.Show(e.Message);
}
finally
{
    // Close the table buffer
    CustomerMasterTable.Close();
}


 



VB Code Example


Dim CustomerMasterTable As RmCustomerMstrTable
CustomerMasterTable = Dynamics.Tables.RmCustomerMstr


Try
    ‘ Read the first row of the table
    CustomerMasterTable.GetFirst()


    ‘ Display the name for the row retrieved
    MsgBox(CustomerMasterTable.CustomerName.Value)


Catch
    MsgBox(Err.Description)


Finally
    ‘ Close the table buffer
    CustomerMasterTable.Close()
End Try


 


Note: Form level table buffers will be closed automatically when the form is closed and so do not need an explicit command.


The situation in the newsgroup post was that another error generated by the code prevented the Close() method from being executed and so left the table buffer open and so caused an error when the user went to exit the application.


Post a comment to let me know find this information helpful.


David

Comments (3)

  1. SteveEndow says:

    Thanks for the post David.  I was doing some testing with VS Tools reading GP table objects, and came across the Exit Aborted message.

    Sure enough, I was not closing the table in my test code!

  2. ian r says:

    I don't know enough programming to understand how to make use of this post.

    Using

    msgroups.net/…/596699

    to make the buyer id auto populate onto a wennsoft (key 2 act) purchase order screen I have run up against this exit aborted.

    the post notes that all id's have to be buyer ids otherwise you will be prompted to add the buyer.  This adding of the buyer is then presumably causing this exit aborted.

    How do I modify the code to get around the error?

    Private Sub BuyerID_BeforeGotFocus(CancelLogic As Boolean)

    Dim usrinfObj As UserInfo

    Dim usrID As String

    Set usrinfObj = VbaGlobal.UserInfoGet()

    usrID = usrinfObj.UserID

    BuyerID = usrID End Sub

    any help is appreciated!

    thanks

  3. Hi Ian

    You would probably want Set usrinfObj = null when you had finished.

    I would also run the code on the Window_AfterOpen event. See this blog post for more info

    blogs.msdn.com/…/quick-tip-solving-quot-do-you-want-to-save-quot-dialog-appearing-after-vba-customization.aspx

    David

Skip to main content