Application Startup and Shutdown

www.altova.com Imprimir este apartado Página anterior Subir un nivel Página siguiente

Inicio >  Referencia del programador > Application API > Overview > Programming Languages > C# >

Application Startup and Shutdown

In the code snippets below, the methods StartAuthenticDesktop_Click and ShutdownAuthenticDesktop_Click are those assigned to buttons in the AutomateAuthenticDesktop example that, respectively, start up and shut down the application. This example is located in the C# folder of the API Examples folder (see the file Form1.cs):

 

Windows 7, Windows 8, Windows 10

C:\Users\<usuario>\Documentos\
Altova\Authentic2019\Authentic

 

You can compile and run the project from within Visual Studio 2008 or Visual Studio 2010.

 

 

 

Starting Authentic Desktop

The following code snippet from the AutomateAuthenticDesktop example shows how to start up the application.

 

  // Handler for the "Start AuthenticDesktop" button

      private void StartAuthenticDesktop_Click(object sender, EventArgs e)

       {

          if (AuthenticDesktop == null)

           {

              Cursor.Current = Cursors.WaitCursor;

 

              // If there is no AuthenticDesktop instance, create one and make it visible.

               AuthenticDesktop = new XMLSpyLib.Application();

               AuthenticDesktop.Visible = true;

 

              Cursor.Current = Cursors.Default;

           }

          else

           {

              // If an instance of Authentic Desktop is already running, make sure it's visible

              if (!AuthenticDesktop.Visible)

                   AuthenticDesktop.Visible = true;

           }

       }

 

 

 

Shutting down Authentic Desktop

The following code snippet from the AutomateAuthenticDesktop example shows how to shut down the application.

 

  // Handler for the "Shut down AuthenticDesktop" button

      // Shut down application instance by explicitely releasing the COM object.

      private void shutdownAuthenticDesktop_Click(object sender, EventArgs e)

       {

          if (AuthenticDesktop != null)

           {

              // Allow shut down of AuthenticDesktop by releasing the UI

               AuthenticDesktop.Visible = false;

 

              // Explicitly release the COM object

              try

               {

                  while (System.Runtime.InteropServices.Marshal.ReleaseComObject(AuthenticDesktop) > 0) ;

               }

              finally

               {

                  // Avoid subsequent access to this object.

                   AuthenticDesktop = null;

               }

           }

       }

 


© 2019 Altova GmbH