I'm developing a custom Extension/Handler for Teamcenter 14.2.1 that needs to send emails. Currently, we're using Teamcenter's built-in tc_mail_smtp
command-line utility, calling it from our C++20/C17 mixed codebase using system()
. The email sending happens at the end of our handler/extension execution, just before it returns.
The problem is that this blocks the UI until email sending completes, causing noticeable delays for users. Email sending is the last operation we perform, so a thread that only lives upto the lifecycle of the handler/extension wont help. We kind of make it run on it's own seperately. Like a daemon/scheduled job. Well, none of our attempts have worked:
- Using
CreateProcess()
withDETACHED_PROCESS
flag:
STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi;
CreateProcess(NULL, cmdLine, NULL, NULL, FALSE,
DETACHED_PROCESS, NULL, NULL, &si, &pi);
The child process seems to terminate when the handler/extension exits. Which is default behaviour on Windows.
- Using Windows
START
command:
system("START /B tc_mail_smtp params > NUL");
This doesn't work (though interestingly, plain START
without /B
does work but freezes the UI).
- Using
std::async
:
auto res = std::async(std::launch::async, [&]() {
system("tc_mail_smtp params");
});
Same issue as approach #1 - the process terminates prematurely.
Environment
- Teamcenter 14.2.1
- Windows Server 2019
- Visual Studio 2022
- C++20/C17 mixed codebase
Question
How can we make the email sending truly asynchronous without blocking the UI, while ensuring the process completes even after the handler/extension returns? Since this is the last operation in our code, threads are kind of not useful here.
As a last resort, we're considering implementing a file-based command-sharing daemon solution to handle the email sending, but we'd prefer a simpler approach if possible.
Additional Context
- The handler/extension is triggered by user actions in Teamcenter
- Email sending is the final operation before the handler returns
- We need to maintain compatibility with Teamcenter's environment
Has anyone encountered similar issues with Teamcenter extensions/handlers and async processes? What's the recommended approach for such scenarios?