From 2385f572d3a52c360e4e6bd08a2383a39b24b197 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sat, 21 May 2022 19:37:41 -0700 Subject: [PATCH] open game programs in seperate thread --- src-tauri/src/system_helpers.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index 2348f78..b56f0bb 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -1,17 +1,16 @@ + +use std::thread; use tauri; use open; #[tauri::command] pub fn run_program(path: String) { // Open the program from the specified path. - // match open::that(path) { - // Ok(_) => (), - // Err(e) => println!("Failed to open program: {}", e), - // }; - match open::with(format!("/c \"{}\"", &path), "C:\\Windows\\System32\\cmd.exe") { - Ok(_) => (), - Err(e) => println!("Failed to open program: {}", e), - }; + + // Open in new thread to prevent blocking + thread::spawn(move || { + open::that(&path).unwrap(); + }); } #[tauri::command]