| 325 | |
| 326 | |
| 327 | bool DbgEngAdapter::ExecuteWithArgs(const std::string& path, const std::string& args, const std::string& workingDir, |
| 328 | const LaunchConfigurations& configs) |
| 329 | { |
| 330 | std::atomic_bool ret = false; |
| 331 | std::atomic_bool finished = false; |
| 332 | // Doing the operation on a different thread ensures the same thread starts the session and runs EngineLoop(). |
| 333 | // This is required by DngEng. Although things sometimes work even if it is violated, it can fail randomly. |
| 334 | std::thread([=, &ret, &finished]() { |
| 335 | ret = ExecuteWithArgsInternal(path, args, workingDir, configs); |
| 336 | finished = true; |
| 337 | if (ret) |
| 338 | EngineLoop(); |
| 339 | }).detach(); |
| 340 | |
| 341 | while (!finished) |
| 342 | {} |
| 343 | return ret; |
| 344 | } |
| 345 | |
| 346 | |
| 347 | bool DbgEngAdapter::ExecuteWithArgsInternal(const std::string& path, const std::string& args, |