Starten und Beenden der Applikation
In den nachstehenden Codefragmenten wurden den Schaltflächen im Beispiel AutomateStyleVision die Methoden StartStyleVision_Click und ShutdownStyleVision_Click zugewiesen. Sie starten bzw. beenden die Applikation. Dieses Beispiel befindet sich im Unterordner C# des Ordners API Examples (siehe Datei Form1.cs):
Windows 7, Windows 8, Windows 10, Windows 11 | C:\Benutzer\<Benutzername>\Dokumente\Altova\StyleVision2026\StyleVisionExamples |
Sie können das Projekt von Visual Studio 2013, 2015, 2017, 2019, 2022, 2026 Insiders aus kompilieren und ausführen.
Starten von StyleVision
Im folgenden Codefragment aus dem Beispiel AutomateStyleVision wird gezeigt, wie man die Applikation startet.
// Handler for the "Start StyleVision" button
private void StartStyleVision_Click(object sender, EventArgs e)
{
if (StyleVision == null)
{
Cursor.Current = Cursors.WaitCursor;
// If there is no StyleVision instance, create one and make it visible.
StyleVision = new StyleVisionLib.Application();
StyleVision.Visible = true;
Cursor.Current = Cursors.Default;
}
else
{
// If an instance of StyleVision is already running, make sure it's visible
if (!StyleVision.Visible)
StyleVision.Visible = true;
}
}
Beenden von StyleVision
Im folgenden Codefragment aus dem Beispiel AutomateStyleVision wird gezeigt, wie man die Applikation beendet.
// Handler for the "Shutdown StyleVision" button
// Shut down the application instance by explicitly releasing the COM object.
private void shutdownStyleVision_Click(object sender, EventArgs e)
{
if (StyleVision != null)
{
// Allow shut-down of StyleVision by releasing UI
StyleVision.Visible = false;
// Explicitly release the COM object
try
{
int i = System.Runtime.InteropServices.Marshal.ReleaseComObject(StyleVision);
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(StyleVision) > 0) ;
}
finally
{
// Disallow subsequent access to this object.
StyleVision = null;
}
}
}