private void openSaveBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { string[] files = (string[])e.Argument; foreach (string file in files) { if (openSaveBackgroundWorker.CancellationPending) { break; } if (File.Exists(file)) { _log.InfoFormat("Processing '{0}'.", file); try { using (var task = new IsolatedTask <OpenSaveTask>()) { task.Proxy.DoOpenSave(file, _openSaveSettings); } } catch (System.Exception ex) { _log.Error(ex.Message, ex); } } } }
private void buttonPrint_Click(object sender, EventArgs e) { // Not necessary but we'll later highlight each one as we print them. foreach (ListViewItem listViewItem in customListView.Items) { listViewItem.Selected = false; } // Loop through all of the files and print them. foreach (ListViewItem listViewItem in customListView.Items) { // GUI sugar. Highligh the item. listViewItem.Selected = true; string filename = listViewItem.Text; DraftPrintUtilityOptions options = (DraftPrintUtilityOptions)listViewItem.Tag; //AppDomain interopDomain = null; try { toolStripStatusLabel.Text = "Setting up an isolated application domation for COM Interop."; toolStripStatusLabel.Text = String.Format("Printing '{0}' in isolated application.", filename); using (var task = new IsolatedTask <BatchPrintTask>()) { task.Proxy.Print(filename, options); } toolStripStatusLabel.Text = String.Empty; } catch (System.Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { listViewItem.Selected = false; } } toolStripStatusLabel.Text = String.Empty; }
private void buttonPrint_Click(object sender, EventArgs e) { // Not necessary but we'll later highlight each one as we print them. foreach (ListViewItem listViewItem in customListView.Items) { listViewItem.Selected = false; } // Loop through all of the files and print them. foreach (ListViewItem listViewItem in customListView.Items) { // GUI sugar. Highligh the item. listViewItem.Selected = true; string filename = listViewItem.Text; DraftPrintUtilityOptions options = (DraftPrintUtilityOptions)listViewItem.Tag; //AppDomain interopDomain = null; try { toolStripStatusLabel.Text = "Setting up an isolated application domation for COM Interop."; toolStripStatusLabel.Text = String.Format("Printing '{0}' in isolated application.", filename); using (var task = new IsolatedTask<BatchPrintTask>()) { task.Proxy.Print(filename, options); } toolStripStatusLabel.Text = String.Empty; } catch (System.Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { listViewItem.Selected = false; } } toolStripStatusLabel.Text = String.Empty; }
static void Main(string[] args) { // Start Solid Edge. var application = SolidEdgeUtils.Connect(true, true); // Disable (most) prompts. application.DisplayAlerts = false; var process = Process.GetProcessById(application.ProcessID); var initialHandleCount = process.HandleCount; var initialWorkingSet = process.WorkingSet64; var trainingFolderPath = SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(); foreach (var fileName in Directory.EnumerateFiles(trainingFolderPath, "*.*", SearchOption.AllDirectories)) { var extension = Path.GetExtension(fileName); if ( (extension.Equals(".asm", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".dft", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".par", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".psm", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".pwd", StringComparison.OrdinalIgnoreCase)) ) { Console.WriteLine("Opening & closing '{0}'", fileName); var startHandleCount = process.HandleCount; var startWorkingSet = process.WorkingSet64; using (var task = new IsolatedTask<OpenCloseTask>()) { task.Proxy.Application = application; task.Proxy.DoOpenClose(fileName); } process.Refresh(); var endHandleCount = process.HandleCount; var endWorkingSet = process.WorkingSet64; Console.WriteLine("Handle count start\t\t'{0}'", startHandleCount); Console.WriteLine("Handle count end\t\t'{0}'", endHandleCount); Console.WriteLine("Handle count change\t\t'{0}'", endHandleCount - startHandleCount); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Handle count total change\t'{0}'", endHandleCount - initialHandleCount); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Working set start\t\t'{0}'", startWorkingSet); Console.WriteLine("Working set end\t\t\t'{0}'", endWorkingSet); Console.WriteLine("Working set change\t\t'{0}'", endWorkingSet - startWorkingSet); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Working set total change\t'{0}'", endWorkingSet - initialWorkingSet); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); } } if (application != null) { application.DisplayAlerts = true; } #if DEBUG System.Diagnostics.Debugger.Break(); #endif }
private void openSaveBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { string[] files = (string[])e.Argument; foreach (string file in files) { if (openSaveBackgroundWorker.CancellationPending) break; if (File.Exists(file)) { _log.InfoFormat("Processing '{0}'.", file); try { using (var task = new IsolatedTask<OpenSaveTask>()) { task.Proxy.DoOpenSave(file, _openSaveSettings); } } catch (System.Exception ex) { _log.Error(ex.Message, ex); } } } }
static void Main(string[] args) { // Start Solid Edge. var application = SolidEdgeUtils.Connect(true, true); // Disable (most) prompts. application.DisplayAlerts = false; var process = Process.GetProcessById(application.ProcessID); var initialHandleCount = process.HandleCount; var initialWorkingSet = process.WorkingSet64; var trainingFolderPath = SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(); foreach (var fileName in Directory.EnumerateFiles(trainingFolderPath, "*.*", SearchOption.AllDirectories)) { var extension = Path.GetExtension(fileName); if ( (extension.Equals(".asm", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".dft", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".par", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".psm", StringComparison.OrdinalIgnoreCase)) || (extension.Equals(".pwd", StringComparison.OrdinalIgnoreCase)) ) { Console.WriteLine("Opening & closing '{0}'", fileName); var startHandleCount = process.HandleCount; var startWorkingSet = process.WorkingSet64; using (var task = new IsolatedTask <OpenCloseTask>()) { task.Proxy.Application = application; task.Proxy.DoOpenClose(fileName); } process.Refresh(); var endHandleCount = process.HandleCount; var endWorkingSet = process.WorkingSet64; Console.WriteLine("Handle count start\t\t'{0}'", startHandleCount); Console.WriteLine("Handle count end\t\t'{0}'", endHandleCount); Console.WriteLine("Handle count change\t\t'{0}'", endHandleCount - startHandleCount); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Handle count total change\t'{0}'", endHandleCount - initialHandleCount); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Working set start\t\t'{0}'", startWorkingSet); Console.WriteLine("Working set end\t\t\t'{0}'", endWorkingSet); Console.WriteLine("Working set change\t\t'{0}'", endWorkingSet - startWorkingSet); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Working set total change\t'{0}'", endWorkingSet - initialWorkingSet); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); } } if (application != null) { application.DisplayAlerts = true; } #if DEBUG System.Diagnostics.Debugger.Break(); #endif }