using System; using ownlibraryfoo; public static class Globals { public static foo_type object1; } class sample_cs { static void Main(string[] args) { Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); try { Globals.object1.initialize(); Globals.object1.runprocess(); Globals.object1.Dispose(); } catch (fooException e) { Console.WriteLine("Error code : " + e.ErrorCode + ". " + e.Message); } return; } static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { Console.WriteLine("Program Terminated Manually"); e.Cancel = true; Globals.object1.Terminate(); bool tryAgain = true; /* query solve status until available and handle exception when not available */ while(tryAgain) { try { if (Globals.object1.Status == FOOINTERRUPTEDSTATUS) { Console.WriteLine(" OBJECTIVE = " + Globals.object1.internalattribute); } tryAgain = false; } catch (FooException f) { /* the error output is optional */ Console.WriteLine("Object1 Error code = " + f.ErrorCode); Console.WriteLine(f.Message); } } Environment.Exit(0); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)