public static TM_Xml_Database queue_Save_GuidanceItemsCache(this TM_Xml_Database tmDatabase) { // do this on a separate thread so that we don't hang the current request var enabled = true; if (enabled && Save_GuidanceItemsCache.isNull()) { Save_GuidanceItemsCache = O2Thread.mtaThread( () => { tmDatabase.sleep(1000, false); tmDatabase.save_GuidanceItemsCache(); Save_GuidanceItemsCache = null; }); } return(tmDatabase); }
public void addReferenceAssembly(string assembly) { References_TreeView.backColor(Color.DarkGray); References_TreeView.enabled(false); O2Thread.mtaThread( () => { AstEngine.ReferencedAssemblies.Add(assembly, null); "...loading reference assembly: {0}".debug(assembly); AstEngine.AstData.O2AstResolver.addReference(assembly); "...load complete".debug(); loadDataInGui(); References_TreeView.backColor(Color.White); References_TreeView.enabled(true); }); }
private void checkIfMailServerIsOnline() { btSendMessage.enabled(false); O2Thread.mtaThread( () => { "Checking to see if we are online".info(); if (Mail.isMailServerOnline(tbMailServer.Text)) { setHostControlsVisibleStatus(true); } else { setHostControlsVisibleStatus(false); } }); }
public void triggerCompilation() { TriggerCompilationThread = O2Thread.mtaThread( () => { this.sleep(500, false); // this will only trigger the compilation when the current thread matches the last one created (which doesn't happen when the user types fast if (Thread.CurrentThread.ManagedThreadId == TriggerCompilationThread.ManagedThreadId) { executeButton.enabled(false); result_RichTextBox.textColor(Color.Gray).set_Text("... compiling ..."); previousCompiledCodeText = currentCode(); compileCodeSnippet(previousCompiledCodeText); } }); }
public void pingAddress(IStep step, string pingTarget) { O2Thread.mtaThread( () => { step.allowNext(false); step.append_Line("Sending a ping request to: " + pingTarget, true, true); var processName = "ping.exe"; var processParams = pingTarget; var process = Processes.startProcessAsConsoleApplication(processName, processParams, (sender, e) => processDataReceived(step, e.Data) , null); process.WaitForExit(); step.append_Line("step completed"); step.allowNext(true); }); }
//(tbCreateTracesForKeyword.Text,cdCirData,dO2TraceBlock,cbOnlyProcessTracesWithNoCallers.Checked private void previewCreatedTraces(List <TreeNode> ltnNormalizedTraces) { O2Thread.mtaThread( () => this.invokeOnThread( () => { if (cbPreviewCreatedTraces.Checked) { tvTempTreeView.Nodes.Clear(); foreach (TreeNode tnTreeNode in ltnNormalizedTraces) { tvTempTreeView.Nodes.Add(tnTreeNode); } } })); }
public void processCirCreationQueue() { if (directory_CirCreationQueue.getFiles().Count > 0) { O2Thread.mtaThread(() => { foreach (var fileInQueue in directory_CirCreationQueue.getFiles()) { // first copy the assembly file to CreatedCirFiles directory var fileToProcess = Files.MoveFile(fileInQueue, directory_CreatedCirFiles.getCurrentDirectory()); // start CirCreation thread createCirDataForFile(fileToProcess, true /*deleteFileOnCompletion*/, false /*decompileCodeIfNoPdb*/); } processCirCreationQueue(); // call it again just in case there was another file in there }); } }
public void graphAllMethods() { O2Thread.mtaThread( () => { var maxNodeSize = 300; foreach (var methodSignature in AllMethods) { addGraphNode(methodSignature); if (maxNodeSize < GraphViewer.nodes().size()) { "in graphAutoExpandAllMethods, maxNode size reached: {0}".error(maxNodeSize); break; } } "graphAllMethods completed".info(); }); }
public static string executeSnippet_SeparateThread(string snippet) { var executionResult = ""; var sync = new AutoResetEvent(false); var thread = O2Thread.mtaThread( () => { executionResult = executeSnippet(snippet); sync.Set(); }); if (thread.Join(MAX_EXECUTION_TIME).isFalse()) { "[REPL] Execution timeout reached".error(); return("Error: Snippet execution timed out"); } return(executionResult); }
public void RefreshDebuggedProcessInformation() { O2Thread.mtaThread(() => { try { O2Forms.populateWindowsControlWithList(lbLoadedAssemblies, DI.o2MDbg.sessionData.getAssemblies()); O2Forms.populateWindowsControlWithList(lbCurrentAppDomains, DI.o2MDbg.sessionData.getAppDomains()); O2Forms.populateWindowsControlWithList(lbCurrentModules, DI.o2MDbg.sessionData.getModules()); O2Forms.populateWindowsControlWithList(lbCurrentThreads, DI.o2MDbg.sessionData.getThreads()); } catch (Exception ex) { DI.log.ex(ex, "in ascx_DebugggedProcessInfo.RefreshDebuggedProcessInformation"); } }); }
public Thread executeFilter(AvailableFilters filterToApply, bool addFindingsWithNoMatches, O2Thread.FuncVoidT1 <List <IO2Finding> > onCompletion) { var o2TargetO2Findings = findingsViewerSourceFindings.currentO2Findings; var o2RulesToUse = rulePackViewer.currentO2RulePack.o2Rules; return(O2Thread.mtaThread( () => { List <IO2Finding> mappedFidings = null; List <IO2Rule> o2Rules = o2RulesToUse.Cast <IO2Rule>().ToList(); switch (filterToApply) { case AvailableFilters.BasicSinksMapping: DI.log.info("Executing filter: BasicSinksMapping"); mappedFidings = Filter_BasicSinksMapping.applyFilter(o2TargetO2Findings, o2Rules); break; case AvailableFilters.CreateAllPartialTraces: DI.log.info("Executing filter: CreateAllPartialTraces"); mappedFidings = Filter_CreateAllPartialTraces.applyFilter(o2TargetO2Findings, o2Rules); break; case AvailableFilters.MapSinksToAllTraces: DI.log.info("Executing filter: MapSinksToAllTraces"); mappedFidings = Filter_MapSinksToAllTraces.applyFilter(o2TargetO2Findings, o2Rules, addFindingsWithNoMatches); break; case AvailableFilters.MapSourcesToAllTraces: DI.log.info("Executing filter: MapSourcesToAllTraces"); mappedFidings = Filter_MapSourcesToAllTraces.applyFilter(o2TargetO2Findings, o2Rules); break; case AvailableFilters.MapFirstSourcesThenSinksToAllTraces: DI.log.info("Executing filter: MapFirstSourcesThenSinksToAllTraces which has two steps"); DI.log.info("Step 1): MapFirstSourcesThenSinksToAllTraces->MapSourcesToAllTraces"); var sourceMappings = Filter_MapSourcesToAllTraces.applyFilter(o2TargetO2Findings, o2Rules); DI.log.info("Step 2): MapFirstSourcesThenSinksToAllTraces->MapSinksToAllTraces"); mappedFidings = Filter_MapSinksToAllTraces.applyFilter(sourceMappings, o2Rules, addFindingsWithNoMatches); break; } if (onCompletion != null) { onCompletion(mappedFidings); } })); }
private void convertJarToDotNetAssembly(string droppedFileOrFolder, string targetDirectory) { if (File.Exists(droppedFileOrFolder)) { O2Thread.mtaThread( () => { directoryToDropJarsToConvertIntoDotNetAssemblies.setDisableMove(false); IKVMUtils.convertJarFileIntoDotNetAssembly(droppedFileOrFolder, targetDirectory); directoryToDropJarsToConvertIntoDotNetAssemblies.setDisableMove(true); }); } else { DI.log.error("in convertJarToDotNetAssembly, only files supported"); } }
public static void backupGac(string zipFileToSaveGacContents) { var pathToGac = Path.Combine(Environment.GetEnvironmentVariable("windir") ?? "", "Assembly");//\\GAC_MSIL"); O2Thread.mtaThread( () => { PublicDI.log.info("Started unzip process of Gac Folder"); var timer = new O2Timer("Gac Backup").start(); //new zipUtils().zipFolder(PublicDI.PathToGac, zipFileToSaveGacContents); new zipUtils().zipFolder(pathToGac, zipFileToSaveGacContents); var logMessage = String.Format("Contents of \n\n\t{0}\n\n saved to \n\n\t{1}\n\n ", pathToGac, zipFileToSaveGacContents); timer.stop(); PublicDI.log.info(logMessage); //PublicDI.log.showMessageBox(logMessage); }); }
/// <summary> /// Executes method /// </summary> /// <param name="mMethodToExecute"></param> /// <param name="dgvSourceCode_SelectedMethodParameters"></param> /// <param name="tbSourceCode_InvocationResult"></param> /// <param name="dgvSourceCode_InvocationResult"></param> /// <param name="oLiveInstanceOfObject"></param> public static Thread executeMethod(MethodInfo mMethodToExecute, DataGridView dgvSourceCode_SelectedMethodParameters, TextBox tbSourceCode_InvocationResult, DataGridView dgvSourceCode_InvocationResult, Object oLiveInstanceOfObject) { return(O2Thread.mtaThread(mMethodToExecute.Name, () => { Object[] aoMethodParameters = DI.reflection.getParameterObjectsFromDataGridColumn( dgvSourceCode_SelectedMethodParameters, "Value"); DI.reflection.executeMethodAndOutputResultInTextBoxOrDataGridView( mMethodToExecute, aoMethodParameters, oLiveInstanceOfObject, tbSourceCode_InvocationResult, dgvSourceCode_InvocationResult); })); }
public TM_Xml_Database(bool useFileStorage) { Current = this; try { O2Thread.mtaThread(CheckIfServerIsOnline); UsingFileStorage = useFileStorage; Setup(); this.setupThread_WaitForComplete(); } catch (Exception ex) { ex.logWithStackTrace("[in TM_Xml_Database.ctor]"); TM_StartUp.Current.TrackingApplication.saveLog(); } }
public static TM_Xml_Database queue_Save_GuidanceItemsCache(this TM_Xml_Database tmDatabase) { if (tmDatabase.UsingFileStorage) { // do this on a separate thread so that we don't hang the current request if (thread_Save_GuidanceItemsCache.isNull()) { thread_Save_GuidanceItemsCache = O2Thread.mtaThread( () => { tmDatabase.sleep(1000, false); tmDatabase.save_GuidanceItemsToCache(); thread_Save_GuidanceItemsCache = null; }); } } return(tmDatabase); }
//[Ignore("No stable on TeamCity (rewrite using Task)")] [Test] public void Test_BlockingCollection_Behaviour() { var submitQueue = new BlockingCollection <API_Firebase.SubmitData>(); Assert.AreEqual(0, submitQueue.size()); var submitData1 = new API_Firebase.SubmitData(); var submitData2 = new API_Firebase.SubmitData(); var submitData3 = new API_Firebase.SubmitData(); var submitData4 = new API_Firebase.SubmitData(); submitQueue.add(submitData1); Assert.AreEqual(1, submitQueue.size()); O2Thread.mtaThread(() => { submitQueue.add(submitData2); 10.sleep(); submitQueue.add(submitData3); 10.sleep(); submitQueue.add(submitData4); }); //note how the next() (i.e. the Take() method) will wait for the data to be available 5.sleep(); Assert.AreEqual(submitQueue.size(), 2); Assert.AreEqual(submitQueue.next(), submitData1); Assert.AreEqual(submitQueue.next(), submitData2); Assert.AreEqual(submitQueue.next(1), null); // with 1 ms wait Assert.AreEqual(submitQueue.size(), 0); Assert.AreEqual(submitQueue.next(), submitData3); Assert.AreEqual(submitQueue.size(), 0); Assert.AreEqual(submitQueue.next(1), null); // with 1 ms wait Assert.AreEqual(submitQueue.next(), submitData4); //test nulls var currentCount = submitQueue.size(); submitQueue.add(null); Assert.AreEqual(currentCount, submitQueue.size()); Assert.IsNull((null as BlockingCollection <API_Firebase.SubmitData>).add(null)); Assert.IsNull((null as BlockingCollection <API_Firebase.SubmitData>).add(new API_Firebase.SubmitData())); Assert.IsNull((null as BlockingCollection <API_Firebase.SubmitData>).next()); }
public bool pasteImageFromClipboard() { if (Clipboard.ContainsImage()) { "Image in Clipboard".debug(); O2Thread.mtaThread( () => { var tempImageTag = "[[Uploading_Image_tmp{0}]]".format(5.randomNumbers()); WikiTextEditor.insertText(tempImageTag); var imageUrl = WikiApi.uploadImage_FromClipboard(); var wikiTextForImage = WikiApi.getWikiTextForImage(imageUrl); WikiTextEditor.replaceText(tempImageTag, wikiTextForImage); }); return(true); } return(false); }
/*private void handleDrop(DragEventArgs e) * { * O2Thread.mtaThread( * ()=> * { * var fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e); * * if (false == loadCirDataFile(fileOrFolder)) * // if (false == loadReferenceFindings(fileOrFolder)) * loadFileOrFolder(fileOrFolder); * }); * }*/ private void handleDropOnDropControl(object oObject, bool processJarFiles, bool deleteTempFiles) { var workingOnTaskFormName = "Running Spring MVC (Annotations) Analysis Engine"; O2AscxGUI.workingOnTaskForm_open(workingOnTaskFormName); O2Thread.mtaThread( () => { Processes.Sleep(500); try { O2AscxGUI.workingOnTaskForm_setText(workingOnTaskFormName, "Prepare files for Analysis (unzip zip, jars, etc..)"); var pythonStringTargetFileOrFolder = AnnotationsHelper.getPythonStringTargetFileOrFolder(oObject.ToString(), processJarFiles); //var tempFolder = DI.config.getTempFolderInTempDirectory("unzipedDroppedZip"); O2AscxGUI.workingOnTaskForm_setText(workingOnTaskFormName, "Converting files (using Jyhton)"); var tempFolderForAnnotationsXmlFiles = AnnotationsHelper.createAnnotationsXmlFilesFromJavaClassFileOrFolder(pythonStringTargetFileOrFolder); var javaXmlFilesToProcess = AnnotationsHelper.calculateFilesToProcess(oObject.ToString(), tempFolderForAnnotationsXmlFiles); O2AscxGUI.workingOnTaskForm_setText(workingOnTaskFormName, "Creating CirData"); var cirData = createCirData(javaXmlFilesToProcess); O2AscxGUI.workingOnTaskForm_setText(workingOnTaskFormName, "Mapping Spring Mvc Controllers"); var springMvcControllers = createSpringMvcControlersObjectsFromXmlFiles(javaXmlFilesToProcess); springMvcMappings.loadMappedControllers(cirData, springMvcControllers); //showSpringMvcControllers(springMvcControllers); if (deleteTempFiles) { Files.deleteFolder(tempFolderForAnnotationsXmlFiles, true); Files.deleteFolder(pythonStringTargetFileOrFolder, true); } else { DI.log.info( "Temp files were not deleted: \n tempFolderForAnnotationsXmlFiles:{0}\n pythonStringTargetFileOrFolder:{1} ", tempFolderForAnnotationsXmlFiles, pythonStringTargetFileOrFolder); } O2AscxGUI.workingOnTaskForm_close(workingOnTaskFormName); } catch (Exception ex) { DI.log.error("in handleDropOnDropControl: {0}", ex.Message); } }); }
public static void ScanWithSelectedAutomaticRuleSets(String sApplicationToScan, String sScanResultsFolder, bool bCallBacksOnControlFlowGraphs_And_ExternalSinks, bool bCallBacksOnEdges_And_ExternalSinks, bool bSourcesAndSinks, String sExtraLogNameText, Callbacks.dMethod_Object dProcessCompletionCallback, Callbacks.dMethod_String logCallback) { O2Thread.mtaThread(() => { DebugMsg.bLogCache = true; // enable LogCache (so that we can save it at the end var srScanResults = new O2scanresults(); //if (File.Exists(CalculateCirDataFileNameInResultsFolder(sApplicationToScan, sScanResultsFolder))) // srScanResults.sCirDataFile = CalculateCirDataFileNameInResultsFolder(sApplicationToScan, sScanResultsFolder); // load or create CirData file if (File.Exists(sApplicationToScan + ".CirData")) { srScanResults.sCirDataFile = sApplicationToScan + ".CirData"; } else { srScanResults.bCreateCirDataFile = true; } // set scanning options (i.e. what to scan) srScanResults.bCallBacksOnControlFlowGraphs_And_ExternalSinks = bCallBacksOnControlFlowGraphs_And_ExternalSinks; srScanResults.bCallBacksOnEdges_And_ExternalSinks = bCallBacksOnEdges_And_ExternalSinks; srScanResults.bSourcesAndSinks = bSourcesAndSinks; srScanResults.dProcessCompletionCallback = dProcessCompletionCallback; srScanResults.logCallback = logCallback; // trigger scan bool bScanResult = srScanResults.scanApplication(sApplicationToScan); // SaveCirDataFile(srScanResults, sScanResultsFolder); //SaveAssessmentFiles(srScanResults, sScanResultsFolder); DebugMsg.saveLogIntoFile(Path.Combine(sScanResultsFolder, Path.GetFileNameWithoutExtension( sApplicationToScan) + " - " + sExtraLogNameText + ".txt")); DebugMsg.bLogCache = false; }); }
public static ComboBox executeScriptOnSelection(this ComboBox comboBox, Items mappings) { comboBox.onSelection <string>( (key) => { if (mappings.hasKey(key)) { comboBox.parent().focus(); // do this in order to prevent a nasty user experience that happens if the user uses the up and down arrows to navigate the comboBox "executing script mapped to '{0}: {1}".info(key, mappings[key]); var itemToExecute = mappings[key]; if (itemToExecute.isUri()) { Processes.startProcess(itemToExecute); } //itemToExecute.startProcess(); else { if (itemToExecute.fileExists().isFalse() && itemToExecute.local().fileExists().isFalse()) { CompileEngine.clearLocalScriptFileMappings(); } "itemToExecute: {0}".debug(itemToExecute); //"itemToExecuteextension: {0}".debug(itemToExecute.extension(".o2")); if (itemToExecute.extension(".h2") || itemToExecute.extension(".o2")) { if (Control.ModifierKeys == Keys.Shift) { "Shift Key pressed, so launching in new process: {0}".info(itemToExecute); itemToExecute.executeH2_or_O2_in_new_Process(); return; } } /* else * { * "Shift Key was pressed, so running script in current process".debug(itemToExecute); * O2Thread.mtaThread(()=>itemToExecute.executeFirstMethod()); * } * else*/ O2Thread.mtaThread(() => itemToExecute.executeFirstMethod()); } } }); return(comboBox); }
public void startMDbg(O2Thread.FuncVoid onShellStart) { if (shell == null) { O2Thread.mtaThread(() => { setMDbgEventsMessagesCallbacks(); shell = new MDbgShell(); shell.Start(new string[0]); setO2MDbgShellCallbacks(); o2MdbgIsReady.Set(); if (onShellStart != null) { onShellStart(); } }); } }
public void stop() { O2Thread.mtaThread( () => { TaskEnabled = false; taskThread.Join(SleepPeriod); // give it time to finish if (taskThread.ThreadState != ThreadState.Stopped) { "Thread was still alive, so aborting it".error(); taskThread.Abort(); } startLinkLabel.enabled(true); stopLinkLabel.enabled(false); messageLabel.visible(false); this.focus(); }); }
public void testMySqlDetails(IStep step) { // run tasks on separate thread O2Thread.mtaThread( () => { step.append_Line("Trying to connect and loging to MySql server \r\n"); if (OunceMySql.isConnectionOpen()) { step.append_Line("ALL OK: Sucessfully connected to MySql database"); } else { step.append_Line("ERROR!: It was not possible to connected to MySql database, check Log Viewer for error details"); } step.append_Line(""); step.append_Line("Test completed"); }); }
/* public static void openScriptEditor() * { * * * }*/ public static void gui() { O2Thread.mtaThread( () => { if (O2AscxGUI.launch("Findings Filter GUI")) { openFindingsViewerAndSourceCodeEditor(); // enable opening findings file references HandleO2MessageOnSD.setO2MessageFileEventListener(); /*KO2MessageQueue.getO2KernelQueue().onMessages += o2Message => HandleO2MessageOnSD. * o2MessageHelper_Handle_IM_FileOrFolderSelected * (o2Message, * null);*/ } }); }
/* public static void openScriptEditor() * { * * * }*/ public static void gui() { O2Cmd.log.write("Opening up GUI"); O2Thread.mtaThread( () => { OunceAvailableEngines.addAvailableEnginesToControl(typeof(ascx_FindingsViewer)); if (O2AscxGUI.launch("O2 Spring MVC")) { HandleO2MessageOnSD.setO2MessageFileEventListener(); //O2AscxGUI.addControlToMenu(typeof (ascx_SpringMvcAnalyzer), O2DockState.Document, // "Experimental - Spring MVC Analyzer"); O2AscxGUI.addControlToMenu(typeof(ascx_PythonCmdShell), O2DockState.Document, "Experimental - Python Cmd Shell"); O2AscxGUI.addControlToMenu(typeof(ascx_Scripts)); O2AscxGUI.openAscx(typeof(ascx_CirDataViewer), O2DockState.DockRight, "Cir Viewer"); O2AscxGUI.openAscx(typeof(ascx_ExploitSpringMvc), O2DockState.Document, "Exploit Spring MVC"); O2AscxGUI.openAscx(typeof(ascx_CreateSpringMvcMappings), O2DockState.Document, "Create Spring MVC Mappings"); //O2AscxGUI.openAscx(typeof(ascx_JoinControllersWithFindings),O2DockState.DockRight, "Cir Viewer"); O2AscxGUI.addControlToMenu(typeof(ascx_FindingsViewer)); //O2AscxGUI.addControlToMenu(typeof(ascx_SourceCodeEditor)); //openFindingsViewerAndSourceCodeEditor(); // enable opening findings file references /*KO2MessageQueue.getO2KernelQueue().onMessages += o2Message => HandleO2MessageOnSD. * o2MessageHelper_Handle_IM_FileOrFolderSelected * (o2Message, * null);*/ } }); O2AscxGUI.waitForAscxGuiClose(); }
public static Form launchGui() { var aspnetCompiler = new DotNet_AspNet_Compiler(); var topPanel = O2Gui.open <Panel>("Tool - Precompile Asp.Net websites", 700, 400); var controls = topPanel.add_1x1("CompilationResult", "Files in output dir"); var compilationResult = controls[0].add_TextArea().wordWrap(false); var filesInOutputDir = controls[1].add_Directory(); var settings = topPanel.insert_Above <Panel>(90); var websiteToCompile = settings.add_Label("Website To Compile:") .append_TextBox("") .align_Right(settings); var targetFolder = settings.add_Label("Target Folder: ", 24, 0) .append_TextBox("") .align_Right(settings); var virtualPath = settings.add_Label("Virtual Path: ", 44, 0) .append_TextBox("") .align_Right(settings); var precompileButton = settings.add_Button("PreCompile Website", 64, 112); precompileButton.append_Link("view aspnet_compiler.exe help", () => aspnetCompiler.show_Help()); precompileButton.onClick( () => { precompileButton.enabled(false); filesInOutputDir.open(targetFolder.get_Text()); O2Thread.mtaThread( () => { compilationResult.set_Text(aspnetCompiler.compile(websiteToCompile.get_Text(), targetFolder.get_Text(), virtualPath.get_Text())); precompileButton.enabled(true); }); }); websiteToCompile.set_Text(@"C:\O2\DemoData\HacmeBank_v2.0 (Dinis version - 7 Dec 08)\HacmeBank_v2_Website"); targetFolder.set_Text(@"C:\O2\DemoData\HacmeBank_Precompiled\Website"); virtualPath.set_Text("/"); return(topPanel.parentForm()); }
private void processDragAndDropFile(DragEventArgs e) { O2Thread.mtaThread(() => { var droppedObject = (FilteredSignature)Dnd.tryToGetObjectFromDroppedObject(e, typeof(FilteredSignature)); if (droppedObject != null) { tbTextSearch.set_Text(droppedObject.sSignature); } else { var fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e); if (fileOrFolder.fileExists()) { loadSourceCodeFile(fileOrFolder); } } }); }
public void ajaxLog(string id, string open, string body, string response) { "Received Ajax Log request".debug(); if (OnAjaxLog.isNull()) { ("id: {0}".line() + "open: {0}".line() + "body: {0}".line() + "response: {0}".line()).format(id, open, body, response); } else { O2Thread.mtaThread( () => { "invoking OnAjaxLog method".info(); OnAjaxLog(id, open, body, response); }); } }
private void btDeleteTempFolderContents_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show( "Are you sure you want to delete the entire contents of the folder " + DI.config.O2TempDir + " ?", "Confirm O2 Temp Folder deletion (after deletion, an empty folder will be created)", MessageBoxButtons.YesNo)) { O2Thread.mtaThread( () => { Threads_ExtensionMethods.invokeOnThread((Control)this, (Func <object>)(() => lbMessage_DeletingTempFolder.Visible = true)); Files.deleteFolder(DI.config.O2TempDir, true); Files.checkIfDirectoryExistsAndCreateIfNot(DI.config.O2TempDir, true); Threads_ExtensionMethods.invokeOnThread((Control)this, (Func <object>)(() => lbMessage_O2TempFolderContentsDeleted.Visible = true)); } ); } }