public bool RunWithoutDebugger() { if (null != vmWorker) { bool isInDebugMode = false; if (vmWorker.IsExecutionActive(ref isInDebugMode)) { return(false); // There's already an on-going execution now. } if (false != vmWorker.IsBusy) { return(false); // There's already an on-going execution now. } } string entryPointCode = GetEntryPointCode(); if (string.IsNullOrEmpty(entryPointCode)) { return(false); // No script to execute. } string errorMessage = string.Empty; IOutputStream messageList = Solution.Current.GetMessage(true); if (hostApplication.PreExecutionSetup(false, ref errorMessage) == false) { messageList.Write(new OutputMessage(OutputMessage.MessageType.Error, errorMessage)); return(false); } if (null == vmWorker) { vmWorker = new VirtualMachineWorker(); vmWorker.ExecutionStateChanged += OnExecutionStateChanged; } try { errorMessage = string.Empty; if (false != hostApplication.PreStepSetup(ref errorMessage)) { // We can execute the script now with the lock. if (vmWorker.RunWithoutDebugger(entryPointCode, messageList)) { return(true); // Call successful. } // Call has failed here, which means we need to inform the host // application instead of waiting for "OnExecutionStateChanged". hostApplication.PostStepTearDown(); hostApplication.PostExecutionTearDown(); } } catch (Exception exception) { } return(false); }
public bool RunWithDebugger(RunMode runMode) { string scriptPath = string.Empty; string errorMessage = string.Empty; if (null == vmWorker) { vmWorker = new VirtualMachineWorker(); vmWorker.ExecutionStateChanged += OnExecutionStateChanged; } // There is an on-going execution right now... bool isInDebugMode = false; if (vmWorker.IsExecutionActive(ref isInDebugMode) == false) { // We only need the script content if the execution has not started. scriptPath = GetEntryScriptPath(); if (string.IsNullOrEmpty(scriptPath) || !File.Exists(scriptPath)) { return(false); // Entry script path not specified or is invalid. } // Prepare the host application for a new execution. if (hostApplication.PreExecutionSetup(true, ref errorMessage) == false) { IOutputStream messageList = Solution.Current.GetMessage(false); messageList.Write(new OutputMessage(OutputMessage.MessageType.Error, errorMessage)); return(false); } } if (false == vmWorker.IsBusy) // Worker isn't busy right now. { if (false != hostApplication.PreStepSetup(ref errorMessage)) { if (vmWorker.RunWithDebugger(scriptPath, runMode)) { return(true); } // Call has failed here, which means we need to inform the host // application instead of waiting for "OnExecutionStateChanged". hostApplication.PostStepTearDown(); hostApplication.PostExecutionTearDown(); } return(false); // Host application isn't quite ready it seems. } return(true); // Call successful. }
public bool RunWithoutDebugger() { if (null != vmWorker) { bool isInDebugMode = false; if (vmWorker.IsExecutionActive(ref isInDebugMode)) return false; // There's already an on-going execution now. if (false != vmWorker.IsBusy) return false; // There's already an on-going execution now. } string entryPointCode = GetEntryPointCode(); if (string.IsNullOrEmpty(entryPointCode)) return false; // No script to execute. string errorMessage = string.Empty; IOutputStream messageList = Solution.Current.GetMessage(true); if (hostApplication.PreExecutionSetup(false, ref errorMessage) == false) { messageList.Write(new OutputMessage(OutputMessage.MessageType.Error, errorMessage)); return false; } if (null == vmWorker) { vmWorker = new VirtualMachineWorker(); vmWorker.ExecutionStateChanged += OnExecutionStateChanged; } try { errorMessage = string.Empty; if (false != hostApplication.PreStepSetup(ref errorMessage)) { // We can execute the script now with the lock. if (vmWorker.RunWithoutDebugger(entryPointCode, messageList)) return true; // Call successful. // Call has failed here, which means we need to inform the host // application instead of waiting for "OnExecutionStateChanged". hostApplication.PostStepTearDown(); hostApplication.PostExecutionTearDown(); } } catch (Exception exception) { } return false; }
public bool RunWithDebugger(RunMode runMode) { string scriptPath = string.Empty; string errorMessage = string.Empty; if (null == vmWorker) { vmWorker = new VirtualMachineWorker(); vmWorker.ExecutionStateChanged += OnExecutionStateChanged; } // There is an on-going execution right now... bool isInDebugMode = false; if (vmWorker.IsExecutionActive(ref isInDebugMode) == false) { // We only need the script content if the execution has not started. scriptPath = GetEntryScriptPath(); if (string.IsNullOrEmpty(scriptPath) || !File.Exists(scriptPath)) return false; // Entry script path not specified or is invalid. // Prepare the host application for a new execution. if (hostApplication.PreExecutionSetup(true, ref errorMessage) == false) { IOutputStream messageList = Solution.Current.GetMessage(false); messageList.Write(new OutputMessage(OutputMessage.MessageType.Error, errorMessage)); return false; } } if (false == vmWorker.IsBusy) // Worker isn't busy right now. { if (false != hostApplication.PreStepSetup(ref errorMessage)) { if (vmWorker.RunWithDebugger(scriptPath, runMode)) return true; // Call has failed here, which means we need to inform the host // application instead of waiting for "OnExecutionStateChanged". hostApplication.PostStepTearDown(); hostApplication.PostExecutionTearDown(); } return false; // Host application isn't quite ready it seems. } return true; // Call successful. }