static void Main() { #if !DEBUG // Exclude the unhandled exception handlers from the Debug version so that the application can be debugged in Visual Studio // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); // Set the unhandled exception mode to force all Windows Forms errors to go through our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ServerForm serverForm = new ServerForm(); Application.Run(serverForm); if (serverForm.RestartApplication) { Application.Restart(); // Restart the application if the network permissions have been changed } #if DEBUG // When debugging, include a log to show the time of close down TraceLogger TL = new TraceLogger("ASCOMRemoteEnded") { Enabled = true }; TL.LogMessage("ASCOMRemoteEnded", "Application has exited"); TL.Enabled = false; TL.Dispose(); TL = null; #endif }
public void Dispose() { // Clean up the tracelogger and util objects tl.Enabled = false; tl.Dispose(); tl = null; }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); try { TL = new TraceLogger("", "SetFireWallRules"); TL.Enabled = true; Version version = Assembly.GetEntryAssembly().GetName().Version; TL.LogMessage("SetFireWallRules", string.Format("Version {0}, Run on {1}", version.ToString(), DateTime.Now.ToString("dddd d MMMM yyyy HH:mm:ss"))); TL.BlankLine(); // Add the event handler for handling non-UI thread exceptions to the event. CommandLine.Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(opts => ProcessOptions(opts)) .WithNotParsed <Options>((errs) => HandleParseError(errs)); TL.Enabled = false; TL = null; } catch (Exception ex) { TraceLogger TL = new TraceLogger("SetFireWallRulesMainException") { Enabled = true }; TL.LogMessageCrLf("Main", "Unhandled exception: " + ex.ToString()); TL.Enabled = false; TL.Dispose(); TL = null; } }
public void Dispose() { traceLogger.Enabled = false; traceLogger.Dispose(); traceLogger = null; serialConnection.Dispose(); }
/// <summary> /// Main program entry point /// </summary> /// <param name="args">Supplied parameters (not used in this program)</param> /// <returns>0 for success, 1 for error</returns> static int Main(string[] args) { try { Dictionary <string, string> vsTemplateDirectoryList; // Dictionary to hold the list of install directories holding templates string TemplateSourceDirectory = ""; vsTemplateDirectoryList = new Dictionary <string, string>(); TL = new TraceLogger("", "InstallTemplates"); // Create a tracelogger so we can log what happens TL.Enabled = true; LogMessage("Main", "Install date: " + DateTime.Now.ToLongDateString()); try { LogMessage("Main", "Installing new templates..."); if (Environment.Is64BitOperatingSystem) { LogMessage("Main", "OS is 64bit"); TemplateSourceDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\ASCOM\Platform 6 Developer Components\Templates"; } else { LogMessage("Main", "OS is 32bit"); TemplateSourceDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\ASCOM\Platform 6 Developer Components\Templates"; } LogMessage("Main", "Template Source Directory: " + TemplateSourceDirectory); // Search registry for template directories vsTemplateDirectoryList = AddTemplateDirectories(FindTemplateDirectoriesInRegistry(Registry.CurrentUser, @"Software\Microsoft\VisualStudio"), vsTemplateDirectoryList); vsTemplateDirectoryList = AddTemplateDirectories(FindTemplateDirectoriesInRegistry(Registry.CurrentUser, @"Software\Microsoft\WDExpress"), vsTemplateDirectoryList); // Search My Documents file system for template directories vsTemplateDirectoryList = AddTemplateDirectories(FindTemplateDirectoriesInFileSystem(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Visual Studio*"), vsTemplateDirectoryList); LogMessage("Main", " "); foreach (KeyValuePair <string, string> templateDir in vsTemplateDirectoryList) // Install new templates in every template directory on this machine { LogMessage("Main", "Installing templates in directory: " + templateDir.Key.ToString()); InstallTemplates(templateDir.Key.ToString(), TemplateSourceDirectory); } } catch (Exception ex) { LogError("Main", ex.ToString()); ReturnCode = 1; } TL.Enabled = false; // Clean up tracelogger TL.Dispose(); TL = null; } catch (Exception ex1) { Console.WriteLine("Exception creating TraceLogger: " + ex1.ToString()); ReturnCode = 99; } return(ReturnCode); }
protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { // Free other state (managed objects). if ((TL != null)) { TL.Enabled = false; TL.Dispose(); TL = null; } } // Free your own state (unmanaged objects) and set large fields to null. try { FreeLibrary(VideoDllHandle); } catch { } } this.disposedValue = true; }
/// <summary> /// Event handler for Profile button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGetProfile_Click(System.Object sender, System.EventArgs e) { TL = new TraceLogger("", TRACE_LOGGER_NAME); TL.Enabled = true; try { txtStatus.Clear(); // Clear the status screen Profile profile = new Profile(); // Create a Profile object profile.DeviceType = CurrentDeviceType; ASCOMProfile deviceProfile = profile.GetProfile(CurrentDevice); // Get the profile of the current device SortedList <string, SortedList <string, string> > results = deviceProfile.ProfileValues; // List each value of the root and all subkeys foreach (KeyValuePair <string, SortedList <string, string> > result in results) { foreach (KeyValuePair <string, string> value in result.Value) { LogMsg(result.Key.ToString(), (value.Key.ToString() == "" ? "<Default>" : value.Key).PadRight(25) + " " + (value.Value == "" ? "<Empty>" : value.Value)); } } profile.Dispose(); } catch (Exception ex) { LogMsg("Error", ex.ToString()); } TL.Enabled = false; TL.Dispose(); }
/// <summary> /// Standart dispose method /// </summary> public void Dispose() { tl.Dispose(); tl = null; DeviceSemaphore.Dispose(); DeviceSemaphore = null; }
/// <summary> /// Standart dispose method /// </summary> public void Dispose() { tl.Dispose(); tl = null; VedrusSemaphore.Dispose(); VedrusSemaphore = null; }
public void Dispose() { Stop(); // Clean up the tracelogger and util objects traceLogger.Enabled = false; traceLogger.Dispose(); traceLogger = null; }
public void Dispose() { // Clean up the trace logger and util objects TL.Enabled = false; TL.Dispose(); TL = null; utilities.Dispose(); utilities = null; }
protected virtual void Dispose(bool dispozing) { if (dispozing) { // Clean up the tracelogger and util objects tl.Enabled = false; tl.Dispose(); tl = null; } }
public void Dispose() { // Clean up the tracelogger, settings form and util objects tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; settingsForm.Dispose(); }
/// <summary> /// Exit button handler - just closes the application /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnExit_Click(object sender, EventArgs e) { TL.LogMessage("Exit", "Closing the application"); TL.Enabled = false; TL.Dispose(); TL = null; Application.Exit(); }
public void Dispose() { tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; astroUtilities.Dispose(); astroUtilities = null; }
public void Dispose() { // Clean up the tracelogger and util objects tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; //astroUtilities.Dispose(); //astroUtilities = null; }
private static IDisposable ActivateLogger() { var logger = new TraceLogger(); Logger = logger; return(new ActionDisposable(() => { logger.Dispose(); Logger = NullLogger.Instance; })); }
protected override void OnDispose(bool disposing) { if (disposing) { if (_logger != null) { _logger.Dispose(); _logger = null; } } }
public void Dispose() { // Clean up the tracelogger and util objects tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; astroUtilities.Dispose(); astroUtilities = null; fMounter.Disconnect(); }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception exception = (Exception)e.ExceptionObject; TraceLogger TL = new TraceLogger("SetNetworkPemissionsException") { Enabled = true }; TL.LogMessageCrLf("Main", "Unhandled exception: " + exception.ToString()); TL.Enabled = false; TL.Dispose(); Environment.Exit(0); }
protected virtual void Dispose(bool disposing) { if (disposing) { try { TL.LogMessage("Dispose", "Dispose called: " + disposing.ToString()); } catch { } //try { Handbox.Close(); } catch { } //try { Handbox.Dispose(); } catch { } try { _moveTimer.Stop(); } catch { } try { _moveTimer.Close(); } catch { } try { _moveTimer.Dispose(); } catch { } try { TL.Enabled = false; } catch { } try { TL.Dispose(); } catch { } } }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception exception = (Exception)e.ExceptionObject; TraceLogger TL = new TraceLogger("RemoteAccessServerException") { Enabled = true }; TL.LogMessageCrLf("Main", "Unhandled exception: " + exception.ToString()); Process.Start(TL.LogFileName); TL.Enabled = false; TL.Dispose(); Environment.Exit(0); }
public void Dispose() { // Clean up the trace logger and util objects Switches.Save(); if (_serial != null) { _serial.Connected = false; } tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; astroUtilities.Dispose(); astroUtilities = null; }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { TraceLogger TL = new TraceLogger("RemoteAccessServerException") { Enabled = true }; TL.LogMessageCrLf("Main", "Thread exception: " + e.Exception.ToString()); Process.Start(TL.LogFileName); TL.Enabled = false; TL.Dispose(); //MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception, see RemoteAccessServerException log for details."); Environment.Exit(0); }
/// <summary> /// Event handler for Properties button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnProperties_Click(System.Object sender, System.EventArgs e) { txtStatus.Clear(); TL = new TraceLogger("", TRACE_LOGGER_NAME); TL.Enabled = true; dynamic driver = null; try { LogMsg("Create", "Creating device"); Type type = Type.GetTypeFromProgID(CurrentDevice); driver = Activator.CreateInstance(type); if (chkConnect.Checked) { LogMsg("Connected", "Setting Connected = True"); driver.Connected = true; LogMsg("Setup", "Opening setup dialogue"); driver.SetupDialog(); LogMsg("Connected", "Setting Connected = False"); driver.Connected = false; } else { LogMsg("Connected", "Not setting Connected = True"); LogMsg("Setup", "Opening setup dialogue"); driver.SetupDialog(); } } catch (Exception ex) { LogMsg("SetupError", ex.Message); } finally { LogMsg("Dispose", "Disposing of device"); try { driver.Dispose(); } catch { } try { Marshal.ReleaseComObject(driver); } catch { } LogMsg("Dispose", "Completed disposal of device"); } TL.Enabled = false; TL.Dispose(); }
public void Dispose() { // Clean up the tracelogger and util objects tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; serialConnection.Dispose(); serialConnection = null; while (queryThreadTask != null && queryThreadTask.Status == TaskStatus.Canceled) { queryThreadTask.Dispose(); queryThreadCts.Dispose(); } }
protected override void Dispose(bool Disposing) { if (Disposing) { if (Form != null) { Form.Dispose(); Form = null; } if (ASCOMTrace != null) { ASCOMTrace.Dispose(); ASCOMTrace = null; } } base.Dispose(Disposing); }
public void Dispose() { if (MyDriverType == 0) { MySSFocuser.Dispose(); } else { // Clean up the tracelogger and util objects tl.Enabled = false; tl.Dispose(); tl = null; utilities.Dispose(); utilities = null; astroUtilities.Dispose(); astroUtilities = null; } }
/// <summary> /// Disposes of managed and unmanged resources /// </summary> /// <param name="disposing">True to dispose of managed resources, false to dispose of unmanged resources</param> protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { if (memberFactory != null) { memberFactory.Dispose(); memberFactory = null; } if (TL != null) { TL.Dispose(); } } } this.disposedValue = true; }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; // Create a trace logger and log the exception TraceLogger TL = new TraceLogger("DynamicClientThreadException") { Enabled = true }; TL.LogMessage("Main", string.Format("ASCOM Dynamic Client Manager - Thread exception. Version: {0}", assemblyVersion.ToString())); TL.LogMessageCrLf("Main", e.Exception.ToString()); // Display the exception in the default .txt editor and exit Process.Start(TL.LogFileName); TL.Enabled = false; TL.Dispose(); Environment.Exit(0); }