Multithread/Background Call to increase performance


This is rather an unusual case as my researches so far yielded me only a little.

I am running a DLL on my project which gets sound from microphone for a duration(which is a parameter), processes it and returns some value(All done by the DLL). However for the duration of DLL’s execution, my game pauses as well. Since it is rather a frequent call and the game is related to timing as well, it creates an unwanted environment. The DLL call is in a blueprint library function and I need to pass some values from blueprints anyway.

My question is, is it possible to make the DLL call not to disrupt the gameplay, be done in the background and whenever it is ready, it then triggers other events and only the call of the DLL(Or the blueprint itself) is related in game? What I need is some sort of multithreading, background call, something that is completely isolated from the gameplay.

I made the same post in Reddit, and the reply was using Multithreading used in here: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

However my concern is, this is a calculation made in multithreading, but I do not really need multithreading to calculate something, I need my calculation to be done in the background so that the game is not paused in that time. Does this solution help me in this manner (The DLL is not process heavy, it only needs to record the sound and the only reason why it takes long is the duration of the sound)? If it does, am I allowed to trigger this with a blueprint and get an event when it returns the value?

In case of obscurities, I can place some screenshots/info about the details of the project.

Thanks in advance.

UE4 Task Graph For Periodic Intense Calculations

Welcome to the forums Naocan!

For small multi-threading tasks where you dont want to incur the overhead of creating a whole new thread, you can use UE4’s Task Graph system!

I have a different wiki on Task Graphing here:

**Task Graph vs New Thread**

The difference with task graphing is that it is for relatively short operations that you dont want to hang up the game thread with.

A new thread would be for things that are constantly running all game long in the background, and require continous CPU power.

Great Use of Task Graph

If you just need to periodically call fancy math functions that then set global vars that you then access from the game thread (or flip a bool to indicate you are done with the task), then Task Graphing is a far better choice.

I wrote a multi-threaded 3D AI navigation/pathfinding system from scratch that runs using the UE4 Task Graph system and it works great! FPS untouched!



Edit: No longer revelant