Preventing Visual Studio Tools customization processes from being terminated by Microsoft Dynamics GP

Just recently I ran into a case on the Microsoft Dynamics GP partner forum where the ISV developer was dealing with a potentially long standing process to be executed from within their Visual Studio Tools (VST) add-in customization. As a result of this long standing process, the developer wanted to prevent Microsoft Dynamics GP from closing while his process was executing.

The Theory Part

Typically, while a process is executing in Microsoft Dynamics GP a user attempting to close the application would receive the following message:

Process are being run message

However, Microsoft Dynamics GP can cause a Visual Studio Tools customization to abruptly shut-down if a user closes the application deliberately or accidentally. Microsoft Dexterity developers have never had to worry about this since Dexterity processes are managed by the call stack.

A call stack is an internal Dexterity mechanism that manages the processing of scripts. Dexterity has eight call stacks; seven are used for foreground processing while the other is used for background processing. When the scripts on a particular call stack have finished processing, the call stack is available to be used again. Scripts in the call stack can be viewed in Process Monitor whether they are foreground, background, or remote processes.

Process(es) in call stack while running a Trial Balance report

In some instances and depending on the type of process, a Dexterity developer have the ability to mark such a process as removable from the call stack, in which case the end-user can take advantage of the Process Monitor window to delete the process from the call stack.

The Solution

In order for a Visual Studio Tools add-in to protect itself from termination by the Microsoft Dynamics GP application while processes are being executed, you can add the following lines of code before and after the process to be executed.

C# Implementation
//tell Dexterity's runtime engine that we are running background.

Microsoft.Dexterity.Shell.DexGlobals.BackgroundProcessesPending++;    
// Execute your process(es) here
//
//
// tell Dexterity runtime engine we're done
Microsoft.Dexterity.Shell.DexGlobals.BackgroundProcessesPending--;


Hopefully you have found this article useful.

Special thanks to Patrick Roth with the Escalation Engineering team in Fargo for posting the response on the partner forum.

Until next post!

MG.-
Mariano Gomez, MVP
Intelligent Partnerships, LLC
http://www.intelligentpartnerships.com/

Comments

Popular posts from this blog

DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

Do I have to use those "Z-" currency IDs in GP?

Microsoft Dynamics GP Scrolling Windows and Line Sequence Numbers