private static void OnShutdown(object sender, EventArgs e) { if (FSBL != null) { lock (lockObj) { // Disable log timer timer.Stop(); if (FSBL != null) { try { // Dispose of Finsemble. FSBL.Dispose(); } catch { } finally { FSBL = null; } } } } // Release main thread so application can exit. autoEvent.Set(); }
/// <summary> /// Handles Finsemble shutdown event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnShutdown(object sender, EventArgs e) { shutdown = true; if (FSBL != null) { lock (lockObj) { if (FSBL != null) { try { removeResponders(); // Dispose of Finsemble. FSBL.Dispose(); } catch { } finally { FSBL = null; //Environment.Exit(0); } } } } // Release main thread so application can exit. autoEvent.Set(); }
/// <summary> /// The OnStartupNextInstance. /// </summary> /// <param name="eventArgs">The eventArgs<see cref="StartupNextInstanceEventArgs"/>.</param> protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) { var nonFSBLArgs = GetNonFinsembleArgs(eventArgs.CommandLine); string name = nonFSBLArgs.First(); Form form = CreateForm(name); var fsbl = new Finsemble(eventArgs.CommandLine.ToArray(), form); fsbl.Connected += (s, e) => { Debug.WriteLine("FSBL connected"); IIntegratable fsblForm = form as IIntegratable; if (fsblForm != null) { fsblForm.SetFinsemble(fsbl); } }; // Dispose of Finsemble object when window is closed. form.Closed += (s, e) => { Debug.WriteLine("disposing window from app.xaml"); fsbl.Dispose(); Debug.WriteLine("dispose completed"); }; fsbl.Connect(); form.Show(); }
public ApplicationContext(string[] args) { var nonFSBLArgs = GetNonFinsembleArgs(args); string name = nonFSBLArgs.First(); Form form = CreateForm(name); var fsbl = new Finsemble(args.ToArray(), form); fsbl.Connected += (s, e) => { Debug.WriteLine("FSBL connected"); IIntegratable fsblForm = form as IIntegratable; if (fsblForm != null) { fsblForm.SetFinsemble(fsbl); } }; // Dispose of Finsemble object when window is closed. form.Closed += (s, e) => { Debug.WriteLine("disposing window from app.xaml"); fsbl.Dispose(); Debug.WriteLine("dispose completed"); }; fsbl.Connect(); this.MainForm = form; this.IsSingleInstance = true; }
private static void OnShutdown(object sender, EventArgs e) { if (FSBL != null) { lock (lockObj) { if (FSBL != null) { try { // Dispose of Finsemble. FSBL.Dispose(); } catch { } finally { FSBL = null; } } } } try { // Release main thread so application can exit. Current.Dispatcher.Invoke(application.Shutdown); } catch { // An error occurred, but I don't care as long as it exits. ; } }
public ApplicationContext(string[] args) { var nonFSBLArgs = GetNonFinsembleArgs(args); string name = nonFSBLArgs.FirstOrDefault(); Form form = CreateForm(name); if (form == null) { MessageBox.Show($"\"{name}\" unknown name of form!"); return; } var fsbl = new Finsemble(args.ToArray(), form); fsbl.Connected += (s, e) => { Debug.WriteLine("FSBL connected"); IIntegratable fsblForm = form as IIntegratable; if (fsblForm != null) { fsblForm.SetFinsemble(fsbl); } }; // Dispose of Finsemble object when window is closed. form.Closed += (s, e) => { Debug.WriteLine("disposing window from app.xaml"); fsbl.Dispose(); Debug.WriteLine("dispose completed"); }; fsbl.Connect("WinformMultiWindowExample", JWK); this.MainForm = form; this.IsSingleInstance = true; }
/// <summary> /// Launches a Finsemble aware window with the passed arguments. /// </summary> /// <param name="args">The arguments passed to the process.</param> /// <returns>Always true?</returns> private static bool LaunchWindow(IList <string> args) { #if DEBUG Debugger.Launch(); #endif if (!args.Any()) { // Invalid number of arguments return(true); } var nonFSBLArgs = GetNonFinsembleArgs(args); if ((nonFSBLArgs == null) || !nonFSBLArgs.Any()) { // no non-finsemble arguments. Cannot launch window. return(true); } string name = nonFSBLArgs.First(); // handle command line arguments of second instance Window window = null; Current.Dispatcher.Invoke(() => { window = CreateWindow(name); }); if (window == null) { Debug.Print($"Could not create window: {name}"); } else { // Register with Finsemble //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble. var fsbl = new Finsemble(args.ToArray(), window); fsbl.Connected += (s, e) => { IIntegratable fsblWin = window as IIntegratable; if (fsblWin == null) { Debug.Print($"The window \"{name}\" is not a window that can be integrated into Finsemble."); } else { fsblWin.SetFinsemble(fsbl); } Current.Dispatcher.Invoke(window.Show); }; // Dispose of Finsemble object when window is closed. window.Closed += (s, e) => { Debug.WriteLine("disposing window from app.xaml"); fsbl.Dispose(); Debug.WriteLine("dispose completed"); }; fsbl.Connect("MultiWindowExample", JWK); } return(true); }